Class: ActiveSnapshot::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/active_snapshot/config.rb

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



3
4
# File 'lib/active_snapshot/config.rb', line 3

def initialize
end

Instance Method Details

#storage_methodObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/active_snapshot/config.rb', line 6

def storage_method
  if @storage_method.nil?
    if ActiveSnapshot::SnapshotItem.table_exists? && ActiveSnapshot::SnapshotItem.type_for_attribute(:object).type == :text
      # for legacy active_snapshot configurations only
      self.storage_method = 'serialized_json'
    else
      self.storage_method = 'native_json'
    end
  end

  @storage_method
end

#storage_method=(value) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/active_snapshot/config.rb', line 19

def storage_method=(value)
  # for legacy active_snapshot configurations only

  value_str = value.to_s

  if ['serialized_yaml', 'serialized_json', 'native_json'].include?(value_str)
    @storage_method = value_str
  else
    raise ArgumentError.new("Invalid storage_method provided")
  end
end

#storage_method_serialized_json?Boolean Also known as: storage_method_json?

Returns:

  • (Boolean)


36
37
38
39
# File 'lib/active_snapshot/config.rb', line 36

def storage_method_serialized_json?
  # for legacy active_snapshot configurations only
  storage_method == 'serialized_json'
end

#storage_method_yaml?Boolean

Returns:

  • (Boolean)


31
32
33
34
# File 'lib/active_snapshot/config.rb', line 31

def storage_method_yaml?
  # for legacy active_snapshot configurations only
  storage_method == 'serialized_yaml'
end