Class: Ubiquitously::Storage::ActiveRecord

Inherits:
Base show all
Defined in:
lib/ubiquitously/support/storage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record, cookies_attribute, credentials_attribute) ⇒ ActiveRecord

Returns a new instance of ActiveRecord.



50
51
52
53
54
# File 'lib/ubiquitously/support/storage.rb', line 50

def initialize(record, cookies_attribute, credentials_attribute)
  self.record = record
  self.cookies_attribute = cookies_attribute
  self.credentials_attribute = credentials_attribute
end

Instance Attribute Details

#cookies_attributeObject

Returns the value of attribute cookies_attribute.



48
49
50
# File 'lib/ubiquitously/support/storage.rb', line 48

def cookies_attribute
  @cookies_attribute
end

#credentials_attributeObject

Returns the value of attribute credentials_attribute.



48
49
50
# File 'lib/ubiquitously/support/storage.rb', line 48

def credentials_attribute
  @credentials_attribute
end

#recordObject

Returns the value of attribute record.



48
49
50
# File 'lib/ubiquitously/support/storage.rb', line 48

def record
  @record
end

Instance Method Details

#loadObject



63
64
65
66
67
68
# File 'lib/ubiquitously/support/storage.rb', line 63

def load
  {
    :cookies => record.read_attribute(cookies_attribute),
    :credentials => record.read_attribute(credentials_attribute)
  }
end

#save(cookies, credentials) ⇒ Object



56
57
58
59
60
61
# File 'lib/ubiquitously/support/storage.rb', line 56

def save(cookies, credentials)
  record.update_attributes(
    cookies_attribute => cookies,
    credentials_attribute => credentials
  )
end