Module: Sh::PluginSugar

Included in:
Plugin
Defined in:
lib/sh_plugin.rb

Instance Method Summary collapse

Instance Method Details

#def_field(*names) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/sh_plugin.rb', line 3

def def_field(*names)
  class_eval do
    names.each do |name|
      define_method(name) do |*args|
        if args.size == 0
          instance_variable_get("@#{name}")
        else
          instance_variable_set("@#{name}", *args)
        end
      end
    end
  end
end