class Trello::AssociationFetcher::HasMany::Params

Attributes

association_name[R]
association_options[R]
association_owner[R]
filter[R]

Public Class Methods

new(association_owner:, association_name:, association_options:, filter:) click to toggle source
# File lib/trello/association_fetcher/has_many/params.rb, line 7
def initialize(association_owner:, association_name:, association_options:, filter:)
  @association_owner = association_owner
  @association_name = association_name
  @association_options = association_options || {}
  @filter = filter || {}
end

Public Instance Methods

association_class() click to toggle source
# File lib/trello/association_fetcher/has_many/params.rb, line 14
def association_class
  association_options[:via] || infer_class_on(association_name)
end
fetch_path() click to toggle source
# File lib/trello/association_fetcher/has_many/params.rb, line 18
def fetch_path
  "/#{parent_restful_resource}/#{parent_restful_resource_id}/#{target_restful_resource}"
end
filter_params() click to toggle source
# File lib/trello/association_fetcher/has_many/params.rb, line 22
def filter_params
  default_filter.merge(filter)
end

Private Instance Methods

default_filter() click to toggle source
# File lib/trello/association_fetcher/has_many/params.rb, line 30
def default_filter
  association_options.reject { |k, _| %w[via in path].include?(k.to_s) }
end
infer_class_on(name) click to toggle source
# File lib/trello/association_fetcher/has_many/params.rb, line 50
def infer_class_on(name)
  AssociationInferTool.infer_class_on_name(name)
end
infer_restful_resource_on(klass) click to toggle source
# File lib/trello/association_fetcher/has_many/params.rb, line 46
def infer_restful_resource_on(klass)
  AssociationInferTool.infer_restful_resource_on_class(klass)
end
parent_restful_resource() click to toggle source
# File lib/trello/association_fetcher/has_many/params.rb, line 34
def parent_restful_resource
  association_options[:in] || infer_restful_resource_on(association_owner.class)
end
parent_restful_resource_id() click to toggle source
# File lib/trello/association_fetcher/has_many/params.rb, line 38
def parent_restful_resource_id
  association_owner.id
end
target_restful_resource() click to toggle source
# File lib/trello/association_fetcher/has_many/params.rb, line 42
def target_restful_resource
  association_options[:path] || association_name
end