module Sphene::Attributes::ClassMethods
Public Instance Methods
attribute(name, type, options = {})
click to toggle source
# File lib/sphene/attributes.rb, line 58 def attribute(name, type, options = {}) name = name.to_sym options[:type] = type attributes[name] = options define_attribute_setter_method(name) define_attribute_getter_method(name) end
attributes()
click to toggle source
# File lib/sphene/attributes.rb, line 71 def attributes @attributes ||= Hash.new({}) end
inherited(base)
click to toggle source
Calls superclass method
# File lib/sphene/attributes.rb, line 66 def inherited(base) super base.instance_variable_set(:@attributes, attributes.dup) end
Private Instance Methods
define_attribute_getter_method(name)
click to toggle source
# File lib/sphene/attributes.rb, line 77 def define_attribute_getter_method(name) define_method(name) do read_attribute(name) end end
define_attribute_setter_method(name)
click to toggle source
# File lib/sphene/attributes.rb, line 83 def define_attribute_setter_method(name) define_method(:"#{name}=") do |value| write_attribute(name, value) end end