module Gearbox::SemanticAccessors::InstanceMethods
Public Class Methods
new(opts={})
click to toggle source
Calls superclass method
# File lib/gearbox/mixins/semantic_accessors.rb, line 40 def initialize(opts={}) super assert_defaults assert_options(opts) @changed_attributes.clear if @changed_attributes end
Public Instance Methods
attributes()
click to toggle source
# File lib/gearbox/mixins/semantic_accessors.rb, line 47 def attributes self.class.attributes.inject({:id => id}) do |hash, (name, opts)| hash[name] = send(name) hash end end
Private Instance Methods
assert_defaults()
click to toggle source
# File lib/gearbox/mixins/semantic_accessors.rb, line 56 def assert_defaults self.class.attributes.each do |name, opts| next unless opts.has_key?(:default) setter = "#{name}=" send(setter, opts[:default]) end end
assert_options(opts)
click to toggle source
# File lib/gearbox/mixins/semantic_accessors.rb, line 64 def assert_options(opts) opts.each do |name, value| setter = "#{name}=" send(setter, value) if respond_to?(setter) end end
attribute_definitions()
click to toggle source
# File lib/gearbox/mixins/semantic_accessors.rb, line 71 def attribute_definitions @attribute_definitions ||= {} end