Module: ParamsReady::Query::AbstractPredicateDefinition::HavingAttribute

Defined in:
lib/params_ready/query/predicate.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



55
56
57
# File 'lib/params_ready/query/predicate.rb', line 55

def self.included(base)
  base.collection :associations, :association
end

Instance Method Details

#alias_select_expression(arel_table, context) ⇒ Object



79
80
81
# File 'lib/params_ready/query/predicate.rb', line 79

def alias_select_expression(arel_table, context)
  build_select_expression(arel_table, context).as(attribute_name.to_s)
end

#attribute_nameObject



64
65
66
# File 'lib/params_ready/query/predicate.rb', line 64

def attribute_name
  @attribute_name || @name
end

#build_select_expression(arel_table, context) ⇒ Object



72
73
74
75
76
77
# File 'lib/params_ready/query/predicate.rb', line 72

def build_select_expression(arel_table, context)
  arel_builder = Helpers::ArelBuilder::Attribute.instance(select_expression, arel_table: @arel_table)
  arel = arel_builder.to_arel(arel_table, context, self)

  arel
end

#select_expressionObject



68
69
70
# File 'lib/params_ready/query/predicate.rb', line 68

def select_expression
  @select_expression || attribute_name
end

#set_attribute(name, select_expression) ⇒ Object



59
60
61
62
# File 'lib/params_ready/query/predicate.rb', line 59

def set_attribute(name, select_expression)
  @attribute_name = name
  @select_expression = select_expression
end