Module: Quby::Questionnaires::DSL::CallsCustomMethods

Included in:
QuestionnaireBuilder, TableBuilder
Defined in:
lib/quby/questionnaires/dsl/calls_custom_methods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



15
16
17
18
19
20
21
# File 'lib/quby/questionnaires/dsl/calls_custom_methods.rb', line 15

def method_missing(method_sym, *args, &block)
  if @custom_methods.key? method_sym
    instance_exec(*args, &custom_methods[method_sym])
  else
    super
  end
end

Instance Attribute Details

#custom_methodsObject (readonly)

Returns the value of attribute custom_methods.



7
8
9
# File 'lib/quby/questionnaires/dsl/calls_custom_methods.rb', line 7

def custom_methods
  @custom_methods
end

Instance Method Details

#initialize(*args) ⇒ Object



9
10
11
12
13
# File 'lib/quby/questionnaires/dsl/calls_custom_methods.rb', line 9

def initialize(*args)
  options = args.last.is_a?(::Hash) ? args.last : {}
  @custom_methods = options[:custom_methods] || {}
  super
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/quby/questionnaires/dsl/calls_custom_methods.rb', line 23

def respond_to_missing?(method_name, include_private = false)
  custom_methods.key?(method_name) || super
end