module MarkMapper::Plugins::Keys::Static
Public Instance Methods
read_key(name)
click to toggle source
Calls superclass method
# File lib/mark_mapper/plugins/keys/static.rb, line 17 def read_key(name) if !self.class.static_keys || self.class.key?(name) super else raise MissingKeyError, "Tried to read the key #{name.inspect}, but no key was defined. Either define key :#{name} or set self.static_keys = false" end end
Private Instance Methods
load_from_database(attrs, with_cast = false)
click to toggle source
Calls superclass method
# File lib/mark_mapper/plugins/keys/static.rb, line 35 def load_from_database(attrs, with_cast = false) return super if !self.class.static_keys || !attrs.respond_to?(:each) attrs = attrs.select { |key, _| self.class.key?(key) } super(attrs, with_cast) end
write_key(name, value)
click to toggle source
Calls superclass method
# File lib/mark_mapper/plugins/keys/static.rb, line 27 def write_key(name, value) if !self.class.static_keys || self.class.key?(name) super else raise MissingKeyError, "Tried to write the key #{name.inspect}, but no key was defined. Either define key :#{name} or set self.static_keys = false" end end