module Ddr::Index::Filter::ClassMethods

Public Instance Methods

has_content() click to toggle source
# File lib/ddr/index/filter.rb, line 78
def has_content
  model "Ddr::Component", "Ddr::Attachment", "Ddr::Target"
end
is_governed_by(arg) click to toggle source
# File lib/ddr/index/filter.rb, line 82
def is_governed_by(arg)
  term admin_policy_id: get_join_id(arg)
end
is_member_of_collection(arg) click to toggle source
# File lib/ddr/index/filter.rb, line 86
def is_member_of_collection(arg)
  term is_member_of_collection: get_id(arg)
end
is_part_of(arg) click to toggle source
# File lib/ddr/index/filter.rb, line 90
def is_part_of(arg)
  term is_part_of: get_id(arg)
end
model(*models) click to toggle source
# File lib/ddr/index/filter.rb, line 94
def model(*models)
  namespaced_models = models.map{ |model| model.starts_with?("Ddr::") ? model : "Ddr::#{model}" }
  where resource_model: namespaced_models
end

Private Instance Methods

get_id(arg) click to toggle source

def get_uri(arg)

case arg
when ActiveFedora::Base
  arg.internal_uri
when String
  arg.start_with?("info:fedora/") ? arg : "info:fedora/#{arg}"
else
  raise TypeError, "Argument must be a String or ActiveFedora::Base instance: #{arg.class}"
end

end

# File lib/ddr/index/filter.rb, line 112
def get_id(arg)
  case arg
    when Ddr::Resource
      arg.id.to_s
    when Valkyrie::ID
      arg.to_s
    when String
      arg
    else
      raise TypeError, "Argument must be a String or Ddr::Resource or Valkyrie::ID instance: #{arg.class}"
  end
end
get_join_id(arg) click to toggle source
# File lib/ddr/index/filter.rb, line 125
def get_join_id(arg)
  "id-#{get_id(arg)}"
end
new_filter() click to toggle source
# File lib/ddr/index/filter.rb, line 129
def new_filter
  Filter.new
end