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.



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

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.



46
47
48
# File 'lib/super_settings/storage/json_storage.rb', line 46

def storage=(value)
  @storage = value
end

Class Method Details

.create!(attributes) ⇒ Object



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

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

Instance Method Details

#created_at=(val) ⇒ Object



48
49
50
# File 'lib/super_settings/storage/json_storage.rb', line 48

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

#save!Object

Raises:

  • (ArgumentError)


52
53
54
55
56
57
58
# File 'lib/super_settings/storage/json_storage.rb', line 52

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

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