Sha256: f58b0f51eee3b5bf73ec27909e1b1fb7fa19f74bb04cc66798e7cbf53b4422e3

Contents?: true

Size: 1001 Bytes

Versions: 35

Compression:

Stored size: 1001 Bytes

Contents

# frozen_string_literal: true

module LinkedRails
  module Model
    module Indexable
      extend ActiveSupport::Concern

      module ClassMethods
        def collection_from_parent(params)
          parent = parent_from_params(params, params[:user_context])
          return if parent.blank?

          collection_name = collection_from_parent_name(parent, params)

          parent.send(collection_name, params) if collection_name
        end

        def root_collection(**params)
          return unless root_collection?

          default_collection_option(:collection_class).collection_or_view(
            default_collection_options,
            params
          )
        end

        private

        def collection_from_parent_name(parent, _params)
          collection_name = "#{name.demodulize.underscore}_collection"

          collection_name if parent.respond_to?(collection_name, true)
        end

        def root_collection?
          true
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
linked_rails-0.0.4.pre.g3aeec2263 lib/linked_rails/model/indexable.rb
linked_rails-0.0.4.pre.gacd5f04d4 lib/linked_rails/model/indexable.rb
linked_rails-0.0.4.pre.gb0b6aea40 lib/linked_rails/model/indexable.rb
linked_rails-0.0.4.pre.g792a1b887 lib/linked_rails/model/indexable.rb
linked_rails-0.0.4.pre.g58af47992 lib/linked_rails/model/indexable.rb
linked_rails-0.0.4.pre.g0ec6e30ca lib/linked_rails/model/indexable.rb
linked_rails-0.0.4.pre.g9e3bcac55 lib/linked_rails/model/indexable.rb
linked_rails-0.0.4.pre.g222bfeeca lib/linked_rails/model/indexable.rb
linked_rails-0.0.4.pre.gb254a2893 lib/linked_rails/model/indexable.rb
linked_rails-0.0.4.pre.g2c6c26e86 lib/linked_rails/model/indexable.rb
linked_rails-0.0.4.pre.ge881247c3 lib/linked_rails/model/indexable.rb
linked_rails-0.0.4.pre.gfabf7e9f5 lib/linked_rails/model/indexable.rb
linked_rails-0.0.4.pre.g8c045be3a lib/linked_rails/model/indexable.rb
linked_rails-0.0.4.pre.g8d7195543 lib/linked_rails/model/indexable.rb
linked_rails-0.0.4.pre.gfe77aae19 lib/linked_rails/model/indexable.rb
linked_rails-0.0.4.pre.gc866c1806 lib/linked_rails/model/indexable.rb
linked_rails-0.0.4.pre.g3e8f5731a lib/linked_rails/model/indexable.rb
linked_rails-0.0.4.pre.g58e27be7f lib/linked_rails/model/indexable.rb
linked_rails-0.0.4.pre.g96885856b lib/linked_rails/model/indexable.rb
linked_rails-0.0.4.pre.g1faca9643 lib/linked_rails/model/indexable.rb