Module: StoreComplex

Defined in:
lib/store_complex.rb,
lib/store_complex/version.rb

Defined Under Namespace

Modules: Accessor

Constant Summary collapse

VERSION =
"0.1.2"

Class Method Summary collapse

Class Method Details

.obj_to_store(value) ⇒ Object



7
8
9
10
# File 'lib/store_complex.rb', line 7

def self.obj_to_store(value)
  return nil if value.nil?
  JSON.generate(value.is_a?(Hash) ? value : Array(value))
end

.store_to_obj(value) ⇒ Object



11
12
13
14
# File 'lib/store_complex.rb', line 11

def self.store_to_obj(value)
  return [] if value.nil?
  JSON.parse(value)
end