Sha256: 6858170b43c33619a8434f11a43afb105beb9215919cb4c53129e593e4d436e8

Contents?: true

Size: 990 Bytes

Versions: 8

Compression:

Stored size: 990 Bytes

Contents

begin
  require 'active_support/ordered_hash'
rescue LoadError
  require 'extlib/dictionary'
  module ActiveSupport
    OrderedHash = Dictionary unless defined?(OrderedHash)
  end
end

require 'dm-core'

module DataMapper
  module Serialize

    def self.dm_validations_loaded?
      DataMapper.const_defined?("Validations")
    end

    # Returns propreties to serialize based on :only or :exclude arrays, if provided
    # :only takes precendence over :exclude
    #
    # @return <Array> properties that need to be serialized
    def properties_to_serialize(options)
      only_properties     = Array(options[:only])
      excluded_properties = Array(options[:exclude])

      model.properties(repository.name).reject do |p|
        if only_properties.include? p.name
          false
        else
          excluded_properties.include?(p.name) || !(only_properties.empty? || only_properties.include?(p.name))
        end
      end
    end

  end
  Model.append_inclusions(Serialize)
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dm-serializer-1.1.0.rc2 lib/dm-serializer/common.rb
dm-serializer-1.1.0.rc1 lib/dm-serializer/common.rb
dm-serializer-1.0.2 lib/dm-serializer/common.rb
dm-serializer-1.0.1 lib/dm-serializer/common.rb
dm-serializer-1.0.0 lib/dm-serializer/common.rb
dm-serializer-1.0.0.rc3 lib/dm-serializer/common.rb
dm-serializer-1.0.0.rc2 lib/dm-serializer/common.rb
dm-serializer-1.0.0.rc1 lib/dm-serializer/common.rb