Class: Stator::Alias
- Inherits:
-
Object
- Object
- Stator::Alias
- Defined in:
- lib/stator/alias.rb
Instance Method Summary collapse
- #evaluate ⇒ Object
-
#initialize(machine, name, options = {}) ⇒ Alias
constructor
A new instance of Alias.
- #is(*args) ⇒ Object
- #is_not(*args) ⇒ Object
- #opposite(*args) ⇒ Object
Constructor Details
#initialize(machine, name, options = {}) ⇒ Alias
Returns a new instance of Alias.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/stator/alias.rb', line 4 def initialize(machine, name, = {}) @machine = machine @name = name @namespace = @machine.namespace @full_name = [@namespace, @name].compact.join('_') @states = [] @not = false @opposite = nil @constant = [:constant] @scope = [:scope] end |
Instance Method Details
#evaluate ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/stator/alias.rb', line 29 def evaluate generate_methods if @opposite op = @machine.state_alias(*@opposite) op.is(*@states) if @not op.is_not(*@states) if !@not end end |
#is(*args) ⇒ Object
16 17 18 |
# File 'lib/stator/alias.rb', line 16 def is(*args) @states |= args.map(&:to_s) end |
#is_not(*args) ⇒ Object
20 21 22 23 |
# File 'lib/stator/alias.rb', line 20 def is_not(*args) @not = true is(*args) end |
#opposite(*args) ⇒ Object
25 26 27 |
# File 'lib/stator/alias.rb', line 25 def opposite(*args) @opposite = args end |