Module: Lite::Command::Internals::Context::ClassMethods
- Defined in:
- lib/lite/command/internals/context.rb
Instance Method Summary collapse
Instance Method Details
#attribute(*args, **options) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/lite/command/internals/context.rb', line 14 def attribute(*args, **) args.each do |method_name| attribute = Lite::Command::Attribute.new(method_name, ) attributes[method_name] = attribute define_method(method_name) do ivar = :"@#{method_name}" return instance_variable_get(ivar) if instance_variable_defined?(ivar) instance_variable_set(ivar, attribute.value) end end end |
#attributes ⇒ Object
28 29 30 |
# File 'lib/lite/command/internals/context.rb', line 28 def attributes @attributes ||= {} end |