Module: Hippo::Concerns::ApiAttributeAccess::ClassMethods

Includes:
AccessChecks
Defined in:
lib/hippo/concerns/set_attribute_data.rb

Instance Method Summary collapse

Methods included from AccessChecks

#can_delete_attributes?, #can_read_attributes?, #can_write_attributes?

Instance Method Details

#blacklist_attributes(*attributes) ⇒ Object

Parameters:

  • attributes (Array of symbols)

    attributes that are not safe for the API to set


44
45
46
47
48
# File 'lib/hippo/concerns/set_attribute_data.rb', line 44

def blacklist_attributes( *attributes )
    options = attributes.extract_options!
    self.blacklisted_attributes ||= DEFAULT_BLACKLISTED.clone
    attributes.each{|attr| self.blacklisted_attributes[ attr.to_sym ] = options }
end

#from_attribute_data(data, user) ⇒ Object


50
51
52
53
54
# File 'lib/hippo/concerns/set_attribute_data.rb', line 50

def from_attribute_data(data,user)
    record = self.new
    record.set_attribute_data(data, user)
    record
end

#whitelist_attributes(*attributes) ⇒ Object

Parameters:

  • attributes (Array of symbols)

    attributes that are safe for the API to set


37
38
39
40
41
# File 'lib/hippo/concerns/set_attribute_data.rb', line 37

def whitelist_attributes( *attributes )
    options = attributes.extract_options!
    self.whitelisted_attributes ||= {}
    attributes.each{|attr| self.whitelisted_attributes[ attr.to_sym ] = options }
end