Class: SuperSettings::Storage::JSONStorage::HistoryStorage

Inherits:
HistoryAttributes show all
Defined in:
lib/super_settings/storage/json_storage.rb

Instance Attribute Summary collapse

Attributes inherited from HistoryAttributes

#changed_by, #created_at, #deleted, #key, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from HistoryAttributes

#deleted?

Methods included from Attributes

#attributes=

Constructor Details

#initializeHistoryStorage

Returns a new instance of HistoryStorage.



30
31
32
33
# File 'lib/super_settings/storage/json_storage.rb', line 30

def initialize(*)
  @storage = nil
  super
end

Instance Attribute Details

#storage=(value) ⇒ Object (writeonly)

Sets the attribute storage

Parameters:

  • value

    the value to set the attribute storage to.



35
36
37
# File 'lib/super_settings/storage/json_storage.rb', line 35

def storage=(value)
  @storage = value
end

Class Method Details

.create!(attributes) ⇒ Object



23
24
25
26
27
# File 'lib/super_settings/storage/json_storage.rb', line 23

def create!(attributes)
  record = new(attributes)
  record.save!
  record
end

Instance Method Details

#created_at=(val) ⇒ Object



37
38
39
# File 'lib/super_settings/storage/json_storage.rb', line 37

def created_at=(val)
  super(TimePrecision.new(val).time)
end

#save!Object

Raises:

  • (ArgumentError)


41
42
43
44
45
46
47
# File 'lib/super_settings/storage/json_storage.rb', line 41

def save!
  raise ArgumentError.new("Missing key") if Coerce.blank?(key)

  @storage.transaction do |changes|
    changes << self
  end
end