Module: HomeQ::Base::Commando::ClassMethods

Included in:
InstanceMethods
Defined in:
lib/homeq/base/commando.rb

Instance Method Summary collapse

Instance Method Details

#config_accessor(sym, help = nil) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/homeq/base/commando.rb', line 39

def config_accessor(sym, help=nil)
  class_eval %{
    document_command("#{sym} [x]", help || "Get/set #{sym}")
    def #{sym}=(*val)
      #{sym}(*val)
    end
    def #{sym}(*val)
      cfg = HomeQ::Base::Configuration::Configuration.instance
      if val.empty?
        cfg.instance_eval("@#{sym}")
      else
        cfg.instance_eval("@#{sym} = val.size == 1 ? val[0] : val")
      end
    end
  }
end

#document_command(name, help) ⇒ Object



36
37
38
# File 'lib/homeq/base/commando.rb', line 36

def document_command(name, help)
  CommandScheme.instance.command_list[name.to_s] = help
end