Class: TwentyFortyEight::Dsl
- Inherits:
-
Object
- Object
- TwentyFortyEight::Dsl
- Defined in:
- lib/TwentyFortyEight/dsl.rb
Overview
Dsl
Instance Attribute Summary collapse
-
#game ⇒ Object
readonly
Returns the value of attribute game.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Instance Method Summary collapse
- #apply(game) ⇒ Object
-
#initialize(settings = {}, &block) ⇒ Dsl
constructor
A new instance of Dsl.
- #method_missing(sym, *args, &block) ⇒ Object
- #respond_to_missing?(sym, *args, &block) ⇒ Boolean
Constructor Details
#initialize(settings = {}, &block) ⇒ Dsl
Returns a new instance of Dsl.
7 8 9 10 |
# File 'lib/TwentyFortyEight/dsl.rb', line 7 def initialize(settings = {}, &block) @callable = block @settings = settings end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
19 20 21 |
# File 'lib/TwentyFortyEight/dsl.rb', line 19 def method_missing(sym, *args, &block) return sym if game.action(sym, insert: false).changed? end |
Instance Attribute Details
#game ⇒ Object (readonly)
Returns the value of attribute game.
5 6 7 |
# File 'lib/TwentyFortyEight/dsl.rb', line 5 def game @game end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
5 6 7 |
# File 'lib/TwentyFortyEight/dsl.rb', line 5 def settings @settings end |
Instance Method Details
#apply(game) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/TwentyFortyEight/dsl.rb', line 12 def apply(game) @queue = [] @game = game.dup instance_eval(&@callable) end |
#respond_to_missing?(sym, *args, &block) ⇒ Boolean
23 24 25 |
# File 'lib/TwentyFortyEight/dsl.rb', line 23 def respond_to_missing?(sym, *args, &block) true end |