Sha256: 5b698bdc943df8cb4886e98b88d7c6bcf1635f00ba7603b49b11a80705727c1a

Contents?: true

Size: 517 Bytes

Versions: 2

Compression:

Stored size: 517 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  module Extensions #:nodoc:
    module Range #:nodoc:
      module Conversions #:nodoc:
        extend ActiveSupport::Concern

        def to_hash
          { "min" => min, "max" => max }
        end

        module ClassMethods #:nodoc:

          def get(value)
            value.nil? ? nil : ::Range.new(value["min"], value["max"])
          end

          def set(value)
            value.nil? ? nil : value.to_hash
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
mongoid-braxton-2.0.2 lib/mongoid/extensions/range/conversions.rb
mongoid-2.0.2 lib/mongoid/extensions/range/conversions.rb