class Rivet::OpenState
Attributes
generated_attributes[R]
required_fields[RW]
Public Class Methods
new()
click to toggle source
# File lib/rivet/common/open_state.rb, line 8 def initialize @generated_attributes = [] end
Public Instance Methods
install_get_or_set(name)
click to toggle source
# File lib/rivet/common/open_state.rb, line 12 def install_get_or_set(name) @generated_attributes << name define_singleton_method(name) do |*args| if args.size < 1 instance_variable_get("@#{name}") else instance_variable_set("@#{name}", args[0]) end end end
method_missing(m, *args, &block)
click to toggle source
Calls superclass method
# File lib/rivet/common/open_state.rb, line 35 def method_missing(m, *args, &block) if args.size < 1 super else install_get_or_set(m) send(m, args[0]) end end
validate()
click to toggle source
# File lib/rivet/common/open_state.rb, line 23 def validate required_fields.each_pair do |method, default_value| unless respond_to?(method) if default_value.nil? fail "Required field #{method} missing!" else send(method, default_value) end end end end