Class: MongoidIceCubeExtension::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/mongoid_ice_cube_extension/rule.rb

Class Method Summary collapse

Class Method Details

.demongoize(value) ⇒ Object


6
7
8
9
10
11
# File 'lib/mongoid_ice_cube_extension/rule.rb', line 6

def demongoize(value)
  case value
  when Hash then IceCube::Rule.from_hash(value)
  else value
  end
end

.evolve(value) ⇒ Object


22
23
24
25
26
27
# File 'lib/mongoid_ice_cube_extension/rule.rb', line 22

def evolve(value)
  case value
  when IceCube::Rule then value.to_hash
  else value
  end
end

.mongoize(value) ⇒ Object


13
14
15
16
17
18
19
20
# File 'lib/mongoid_ice_cube_extension/rule.rb', line 13

def mongoize(value)
  case value
  when 'null' then nil
  when IceCube::Rule then value.to_hash
  when String then IceCube::Rule.from_hash(JSON.parse(value)).to_hash
  else value
  end
end