Class: Prospectus::StateDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/prospectus/state.rb

Overview

DSL for wrapping eval of states

Instance Method Summary collapse

Constructor Details

#initialize(state, params) ⇒ StateDSL

Returns a new instance of StateDSL.



23
24
25
26
# File 'lib/prospectus/state.rb', line 23

def initialize(state, params)
  @state = state
  @options = params
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



36
37
38
39
40
41
# File 'lib/prospectus/state.rb', line 36

def method_missing(method, *args, &block)
  return super if @module
  @module = Prospectus.modules.find(method)
  return super unless @module
  extend @module
end

Instance Method Details

#respond_to_missing?(method, _ = false) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
34
# File 'lib/prospectus/state.rb', line 28

def respond_to_missing?(method, _ = false)
  return super if @module
  Prospectus.modules.find(method)
  true
rescue RuntimeError
  super
end