Module: Cognizant::Util::DSLProxyMethodsHandler

Included in:
Application::DSLProxy, Process::DSLProxy
Defined in:
lib/cognizant/util/dsl_proxy_methods_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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


10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/cognizant/util/dsl_proxy_methods_handler.rb', line 10

def method_missing(name, *args, &block)
  if args.size == 1 and name.to_s =~ /^(.*)=$/
    @attributes[$1.to_sym] = args.first
  elsif args.size == 1
    @attributes[name.to_sym] = args.first
  elsif args.size == 0 and name.to_s =~ /^(.*)!$/
    @attributes[$1.to_sym] = true
  elsif args.empty? and @attributes.key?(name.to_sym)
    @attributes[name.to_sym]
  else
    super
  end
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes


4
5
6
# File 'lib/cognizant/util/dsl_proxy_methods_handler.rb', line 4

def attributes
  @attributes
end

Instance Method Details

#initialize(entity, &dsl_block) ⇒ Object


6
7
8
# File 'lib/cognizant/util/dsl_proxy_methods_handler.rb', line 6

def initialize(entity, &dsl_block)
  @attributes = Hash.new
end