class Excom::Plugins::Executable::State
Public Class Methods
add_prop(*props)
click to toggle source
# File lib/excom/plugins/executable.rb, line 12 def self.add_prop(*props) prop_names.push(*props) props.each{ |prop| def_prop_accessor(prop) } end
def_prop_accessor(name)
click to toggle source
# File lib/excom/plugins/executable.rb, line 17 def self.def_prop_accessor(name) define_method(name) { @values[name] } define_method("#{name}=") { |value| @values[name] = value } define_method("has_#{name}?") { @values.key?(name) } end
new(values = {})
click to toggle source
# File lib/excom/plugins/executable.rb, line 23 def initialize(values = {}) @values = values end
prop_names()
click to toggle source
# File lib/excom/plugins/executable.rb, line 8 def self.prop_names @prop_names ||= [] end
Public Instance Methods
clear!()
click to toggle source
# File lib/excom/plugins/executable.rb, line 27 def clear! @values.clear end
prop_names()
click to toggle source
# File lib/excom/plugins/executable.rb, line 31 def prop_names self.class.prop_names end
replace(other)
click to toggle source
# File lib/excom/plugins/executable.rb, line 35 def replace(other) missing_props = prop_names - other.prop_names unless missing_props.empty? raise ArgumentError, "cannot accept execution state #{other} due to missing props: #{missing_props}" end prop_names.each do |prop| @values[prop] = other.public_send(prop) end end