Skip to content

Instantly share code, notes, and snippets.

@valterbarros
Last active April 18, 2018 19:53
Show Gist options
  • Save valterbarros/cefed0fd1682ab8a03d7aec52c240756 to your computer and use it in GitHub Desktop.
Save valterbarros/cefed0fd1682ab8a03d7aec52c240756 to your computer and use it in GitHub Desktop.
class ApplicationController; end
module Planning; end
class PlanningContoller < ApplicationController
def index
Planning::Index.new(planning_params).run do |parameters|
create_planning(parameters)
render :index, status: 200
end
end
private
def render type, status
puts '<html></html>'
end
def create_planning; true end
def planning_params
{ people: 'roberto', planning_ids: [1,2,3,4,5,6] }
end
end
module Planning
class Index < ApplicationController
attr_reader :params
def initialize(params)
@params = params
end
def run
parameters = prepare_params params
yield(parameters)
end
end
private
def prepare_params
params.delete_if{ |param| param.blank? }
end
def remove_people_from_params
params.except(:people)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment