Skip to content

Instantly share code, notes, and snippets.

@guipdutra
Created December 26, 2013 11:20
Show Gist options
  • Select an option

  • Save guipdutra/8132498 to your computer and use it in GitHub Desktop.

Select an option

Save guipdutra/8132498 to your computer and use it in GitHub Desktop.
class CellSupervisionNameFunctionsBusiness
def initialize(options)
@functions = options.fetch(:functions)
end
def save!
functions.each do |function|
if function[:id] == CellSupervisionFunctionItem::NEW
new_function_name(function)
else
update_function_name(function)
end
end
end
private
attr_reader :organization, :functions
def update_function_name(function)
cell_supervison_name(function[:id]).update_attributes(function)
end
def new_function_name(function)
CellSupervisionFunction.create(function)
end
def cell_supervison_name(id)
CellSupervisionFunction.find(id)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment