Created
December 26, 2013 11:20
-
-
Save guipdutra/8132498 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 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