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.



35
36
37
38
# File 'lib/prospectus/state.rb', line 35

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



48
49
50
51
52
53
# File 'lib/prospectus/state.rb', line 48

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)


40
41
42
43
44
45
46
# File 'lib/prospectus/state.rb', line 40

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