Sha256: 74f32ca9da9a58af6aa0858b81b902735f3dad65f2fc15599fd3e6bcb2514142

Contents?: true

Size: 611 Bytes

Versions: 5

Compression:

Stored size: 611 Bytes

Contents

require 'ice_cube'

module MongoidIceCubeExtension
  class Rule
    class << self
      def demongoize(value)
        case value
        when Hash then IceCube::Rule.from_hash(value)
        else value
        end
      end

      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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mongoid_ice_cube_extension-0.2.4 lib/mongoid_ice_cube_extension/rule.rb
mongoid_ice_cube_extension-0.2.3 lib/mongoid_ice_cube_extension/rule.rb
mongoid_ice_cube_extension-0.2.2 lib/mongoid_ice_cube_extension/rule.rb
mongoid_ice_cube_extension-0.2.1 lib/mongoid_ice_cube_extension/rule.rb
mongoid_ice_cube_extension-0.2.0 lib/mongoid_ice_cube_extension/rule.rb