Module: Freyr::ServiceInfo::Base::ClassMethods

Defined in:
lib/freyr/service_info.rb

Instance Method Summary collapse

Instance Method Details

#add_service_method(*methods) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/freyr/service_info.rb', line 21

def add_service_method *methods
  Service.send :add_service_method, *methods
  Command.send :add_service_method, *methods
  methods.each do |method|
    InstanceMethods.instance_eval do
      define_method method do |*args|
        val = args
        val = val.first if val.size < 2
        if val
          MODIFIERS[method].each do |mod|
            val = send(mod,val)
          end
          instance_variable_set("@#{method}",val)
        else
          instance_variable_get("@#{method}")
        end
      end
      
    end

  end
end