Module: Blackbeard::StorableAttributes::InstanceMethods

Defined in:
lib/blackbeard/storable_attributes.rb

Instance Method Summary collapse

Instance Method Details

#attributes_hash_keyObject



47
48
49
# File 'lib/blackbeard/storable_attributes.rb', line 47

def attributes_hash_key
  "#{key}::attributes"
end

#storable_attributes_hashObject



43
44
45
# File 'lib/blackbeard/storable_attributes.rb', line 43

def storable_attributes_hash
  @storable_attributes ||= db.hash_get_all(attributes_hash_key)
end

#update_attributes(tainted_params) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/blackbeard/storable_attributes.rb', line 35

def update_attributes(tainted_params)
  attributes = self.class.storable_attributes
  safe_attributes = tainted_params.keys.select{ |k| attributes.include?(k.to_sym) }
  safe_attributes.each do |attribute|
    self.send("#{attribute}=".to_sym, tainted_params[attribute])
  end
end