Class: ActionFactory::AssignmentCompiler
- Inherits:
-
Object
- Object
- ActionFactory::AssignmentCompiler
- Defined in:
- lib/action_factory/assignment_compiler.rb
Instance Method Summary collapse
- #compile(assignments, only: nil, except: []) ⇒ Object
-
#initialize(factory) ⇒ AssignmentCompiler
constructor
A new instance of AssignmentCompiler.
Constructor Details
#initialize(factory) ⇒ AssignmentCompiler
Returns a new instance of AssignmentCompiler.
6 7 8 |
# File 'lib/action_factory/assignment_compiler.rb', line 6 def initialize(factory) @factory = factory end |
Instance Method Details
#compile(assignments, only: nil, except: []) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/action_factory/assignment_compiler.rb', line 10 def compile(assignments, only: nil, except: []) if only.present? && except.present? raise ArgumentError, "Cannot use both 'only' and 'except' options" end assignments = assignments.slice(*only) unless only.nil? assignments.except(*except).transform_values do |assignment| assignment.compile(@factory) end end |