Module: Excom::Plugins::Args::ClassMethods

Defined in:
lib/excom/plugins/args.rb

Instance Method Summary collapse

Instance Method Details

#arg_methodsObject



80
81
82
# File 'lib/excom/plugins/args.rb', line 80

def arg_methods
  const_get(:ArgMethods)
end

#args(*argz) ⇒ Object



84
85
86
87
88
89
90
91
92
# File 'lib/excom/plugins/args.rb', line 84

def args(*argz)
  args_list.concat(argz)

  argz.each_with_index do |name, i|
    arg_methods.send(:define_method, name){ @args[i] }

    arg_methods.send(:define_method, "#{name}?"){ !!@args[i] }
  end
end

#args_listObject



104
105
106
# File 'lib/excom/plugins/args.rb', line 104

def args_list
  @args_list ||= []
end

#inherited(service_class) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/excom/plugins/args.rb', line 72

def inherited(service_class)
  service_class.const_set(:ArgMethods, Module.new)
  service_class.send(:include, service_class::ArgMethods)
  service_class.args_list.replace args_list.dup
  service_class.opts_list.replace opts_list.dup
  super
end

#opts(*optz) ⇒ Object



94
95
96
97
98
99
100
101
102
# File 'lib/excom/plugins/args.rb', line 94

def opts(*optz)
  opts_list.concat(optz)

  optz.each do |name|
    arg_methods.send(:define_method, name){ @opts[name] }

    arg_methods.send(:define_method, "#{name}?"){ !!@opts[name] }
  end
end

#opts_listObject



108
109
110
# File 'lib/excom/plugins/args.rb', line 108

def opts_list
  @opts_list ||= []
end