Sha256: 7a06a2e3b910fe6902ce97a2101cf4b3deb54dcbb39b05f7fbd9963868af459b
Contents?: true
Size: 1.89 KB
Versions: 1
Compression:
Stored size: 1.89 KB
Contents
require "forwardable" require "virtus" module Ddr::Index class Filter include Virtus.model attribute :clauses, Array, default: [ ] def ==(other) other.instance_of?(self.class) && (other.clauses == self.clauses) end module Api def raw(*clauses) self.clauses += clauses self end def term(conditions) self.clauses += conditions.map { |f, v| QueryClause.term(f, v) } self end def where(conditions) self.clauses += conditions.map { |f, v| QueryClause.where(f, v) } self end def absent(field) self.clauses << QueryClause.absent(field) self end def present(field) self.clauses << QueryClause.present(field) self end def negative(field, value) self.clauses << QueryClause.negative(field, value) self end def before(field, value) self.clauses << QueryClause.before(field, value) self end def before_days(field, value) self.clauses << QueryClause.before_days(field, value) self end end module ClassMethods extend Forwardable delegate Api.public_instance_methods => :new_filter def has_content where active_fedora_model: [ "Component", "Attachment", "Target" ] end def is_governed_by(object_or_id) term is_governed_by: internal_uri(object_or_id) end def is_member_of_collection(object_or_id) term is_member_of_collection: internal_uri(object_or_id) end private def internal_uri(object_or_id) if object_or_id.respond_to?(:internal_uri) object_or_id.internal_uri else ActiveFedora::Base.internal_uri(object_or_id) end end def new_filter Filter.new end end include Api extend ClassMethods end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ddr-models-2.4.0.rc5 | lib/ddr/index/filter.rb |