Class: Interfacets::Shared::Entities::Specs::Action

Inherits:
Object
  • Object
show all
Includes:
Acceptable
Defined in:
lib/interfacets/shared/entities/specs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Acceptable

#accepted_by?, #standardized_accepted_by

Constructor Details

#initialize(name:, accepted_by:, only_if_valid:) ⇒ Action

Returns a new instance of Action.



35
36
37
38
39
# File 'lib/interfacets/shared/entities/specs.rb', line 35

def initialize(name:, accepted_by:, only_if_valid:)
  @name = name
  @accepted_by = accepted_by
  @only_if_valid = only_if_valid
end

Instance Attribute Details

#accepted_by ⇒ Object (readonly)

Returns the value of attribute accepted_by.



34
35
36
# File 'lib/interfacets/shared/entities/specs.rb', line 34

def accepted_by
  @accepted_by
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



34
35
36
# File 'lib/interfacets/shared/entities/specs.rb', line 34

def name
  @name
end

#only_if_valid ⇒ Object (readonly)

Returns the value of attribute only_if_valid.



34
35
36
# File 'lib/interfacets/shared/entities/specs.rb', line 34

def only_if_valid
  @only_if_valid
end

Instance Method Details

#dispatch(entity) ⇒ Object



44
45
46
47
48
# File 'lib/interfacets/shared/entities/specs.rb', line 44

def dispatch(entity)
  if !only_if_valid || entity.valid?
    entity.send(name)
  end
end

#type ⇒ Object



42
# File 'lib/interfacets/shared/entities/specs.rb', line 42

def type = :action