class Ppl::Application::Command

Attributes

storage[RW]

Public Class Methods

add_instance_property_getter(property_name) click to toggle source
# File lib/ppl/application/command.rb, line 34
def self.add_instance_property_getter(property_name)
  define_method(property_name) do
    instance_variable = instance_variable_get("@#{property_name}")
    class_variable    = @@property_values[property_name][self.class]
    if !instance_variable.nil?
      instance_variable
    elsif !class_variable.nil?
      class_variable
    end
  end
end
add_instance_property_setter(property_name) click to toggle source
# File lib/ppl/application/command.rb, line 46
def self.add_instance_property_setter(property_name)
  define_method("#{property_name}=") do |value|
    instance_variable_set("@#{property_name}", value)
  end
end
add_property(name) click to toggle source
# File lib/ppl/application/command.rb, line 14
def self.add_property(name)
  @@property_values[name] = {}
  self.add_static_property_setter(name)
  self.add_instance_property_getter(name)
  self.add_instance_property_setter(name)
end
add_static_property_setter(property_name) click to toggle source
# File lib/ppl/application/command.rb, line 24
def self.add_static_property_setter(property_name)
  define_singleton_method(property_name) do |value = nil|
    if value.nil?
      @@property_values[property_name][self]
    else
      @@property_values[property_name][self] = value
    end
  end
end

Public Instance Methods

execute(input, output) click to toggle source
# File lib/ppl/application/command.rb, line 7
def execute(input, output)
  raise NotImplementedError
end
options(parser, options) click to toggle source
# File lib/ppl/application/command.rb, line 11
def options(parser, options)
end