Class: RapidTransit::Action::ClassMethod
- Defined in:
- lib/rapid_transit/action/class_method.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#model ⇒ Object
Returns the value of attribute model.
Attributes inherited from Base
#action_name, #block, #condition, #key, #options
Instance Method Summary collapse
-
#initialize(action_name, model_name, *args) ⇒ ClassMethod
constructor
A new instance of ClassMethod.
- #requires_attributes? ⇒ Boolean
- #result_saved? ⇒ Boolean
Methods inherited from Base
Constructor Details
#initialize(action_name, model_name, *args) ⇒ ClassMethod
Returns a new instance of ClassMethod.
5 6 7 8 9 10 11 |
# File 'lib/rapid_transit/action/class_method.rb', line 5 def initialize(action_name, model_name, *args) super @model = @key.to_s.camelize.constantize @attributes = args..stringify_keys @key = args.first unless args.empty? @validations += [:model, :attributes] end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/rapid_transit/action/class_method.rb', line 3 def attributes @attributes end |
#model ⇒ Object
Returns the value of attribute model.
3 4 5 |
# File 'lib/rapid_transit/action/class_method.rb', line 3 def model @model end |
Instance Method Details
#requires_attributes? ⇒ Boolean
17 18 19 |
# File 'lib/rapid_transit/action/class_method.rb', line 17 def requires_attributes? action_name != :new end |
#result_saved? ⇒ Boolean
13 14 15 |
# File 'lib/rapid_transit/action/class_method.rb', line 13 def result_saved? ![:new, :find_or_initialize].include? action_name end |