Class: RapidTransit::Action::ClassMethod

Inherits:
Base
  • Object
show all
Defined in:
lib/rapid_transit/action/class_method.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#action_name, #block, #condition, #key, #options

Instance Method Summary collapse

Methods inherited from Base

#apply?, #result, #valid?

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.extract_options!.stringify_keys
  @key = args.first unless args.empty?
  @validations += [:model, :attributes]
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



3
4
5
# File 'lib/rapid_transit/action/class_method.rb', line 3

def attributes
  @attributes
end

#modelObject

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

Returns:

  • (Boolean)


17
18
19
# File 'lib/rapid_transit/action/class_method.rb', line 17

def requires_attributes?
  action_name != :new
end

#result_saved?Boolean

Returns:

  • (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