Sha256: d3ac0d3ce7104f3d8c9407685da4bbfee80965f3f2af4f3965deb7648542dc1c

Contents?: true

Size: 707 Bytes

Versions: 5

Compression:

Stored size: 707 Bytes

Contents

module DataMapper
  module Serialize
    # 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])

      self.class.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

  module Resource
    include Serialize
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
dm-serializer-0.9.9 lib/dm-serializer/common.rb
dm-serializer-0.9.11 lib/dm-serializer/common.rb
dm-serializer-0.9.10 lib/dm-serializer/common.rb
mack-data_mapper-0.8.3.1 lib/gems/dm-serializer-0.9.9/lib/dm-serializer/common.rb
mack-data_mapper-0.8.3 lib/gems/dm-serializer-0.9.9/lib/dm-serializer/common.rb