Class: ParamsReady::Query::PolymorphPredicateBuilder

Inherits:
AbstractPredicateBuilder show all
Includes:
HavingValue
Defined in:
lib/params_ready/query/polymorph_predicate.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Extensions::Registry

#human_string, #registry

Methods inherited from AbstractBuilder

#build, builder, define_parameter, define_registered_parameter, #fetch, fetch_builder, #include, #initialize, #open?, register, register_deprecated, resolve

Constructor Details

This class inherits a constructor from ParamsReady::AbstractBuilder

Class Method Details

.instance(name, altn: nil) ⇒ Object



35
36
37
# File 'lib/params_ready/query/polymorph_predicate.rb', line 35

def self.instance(name, altn: nil)
  new PolymorphPredicateDefinition.new name, altn: altn
end

Instance Method Details

#identifier(identifier) ⇒ Object



46
47
48
# File 'lib/params_ready/query/polymorph_predicate.rb', line 46

def identifier(identifier)
  @definition.set_identifier(identifier)
end

#type(type_name, *args, **opts, &block) ⇒ Object



39
40
41
42
43
44
# File 'lib/params_ready/query/polymorph_predicate.rb', line 39

def type(type_name, *args, **opts, &block)
  builder = PredicateRegistry.predicate(type_name).instance(*args, **opts)
  builder.instance_eval(&block) unless block.nil?
  type = builder.build
  @definition.add_type type
end