Module: Quby::Compiler::DSL::CallsCustomMethods

Included in:
QuestionnaireBuilder, TableBuilder
Defined in:
lib/quby/compiler/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, **kwargs, &block) ⇒ Object



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

def method_missing(method_sym, *args, **kwargs, &block)
  if @custom_methods.key? method_sym
    instance_exec(*args, **kwargs, &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/compiler/dsl/calls_custom_methods.rb', line 7

def custom_methods
  @custom_methods
end

Instance Method Details

#initialize(*args, **options) ⇒ Object



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

def initialize(*args, **options)
  @custom_methods = options[:custom_methods] || {}
  super
end

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

Returns:

  • (Boolean)


22
23
24
# File 'lib/quby/compiler/dsl/calls_custom_methods.rb', line 22

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