Sha256: 7888c4483332d152263bbc9d7bb491152df9024715d95e9ba52bdcbb35be91c3

Contents?: true

Size: 744 Bytes

Versions: 6

Compression:

Stored size: 744 Bytes

Contents

require 'dm-core'

module DataMapper
  module Serializer

    # 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(Serializer)
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
ardm-serializer-1.2.2 lib/dm-serializer/common.rb
dm-serializer-1.2.2 lib/dm-serializer/common.rb
dm-serializer-1.2.1 lib/dm-serializer/common.rb
dm-serializer-1.2.0 lib/dm-serializer/common.rb
dm-serializer-1.2.0.rc2 lib/dm-serializer/common.rb
dm-serializer-1.2.0.rc1 lib/dm-serializer/common.rb