Sha256: 6594fb87f0b0d8380cc9558e97e95320e634fccc32b4ad2cfddd39f018d85b4d

Contents?: true

Size: 905 Bytes

Versions: 1

Compression:

Stored size: 905 Bytes

Contents

require 'trailblazer/finder/adapters/data_mapper/paging'
# require 'trailblazer/finder/adapters/data_mapper/sorting'

module Trailblazer
  class Finder
    module Adapters
      # ActiveRecord Adapter
      module DataMapper
        def self.included(base)
          base.extend ClassMethods
        end

        module ClassMethods
          # :nocov:
          def normalize_find_handler(handler, key)
            case handler
            when Symbol then ->(entity_type, value) { method(handler).call entity_type, value }
            when Proc then handler
            else ->(entity_type, value) { entity_type.all(key.to_sym => value) unless Utils::String.blank?(value) }
            end
          end
          # :nocov:
        end

        include Paging if defined?(Features::Paging::ClassMethods)
        # include Sorting if defined?(Features::Sorting::ClassMethods)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trailblazer-finder-0.1.3 lib/trailblazer/finder/adapters/data_mapper.rb