Last active
April 18, 2018 19:53
-
-
Save valterbarros/cefed0fd1682ab8a03d7aec52c240756 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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