Module: RequiredQueryAttributes::Model::ClassMethods
- Defined in:
- lib/required_query_attributes/model.rb
Instance Attribute Summary collapse
-
#required_query_attributes ⇒ Object
readonly
Returns the value of attribute required_query_attributes.
Class Method Summary collapse
Instance Method Summary collapse
-
#require_query_attribute(attribute) ⇒ Object
Declare this in your model to enforce that the provided attribute must be used in at least one condition on SELECT statements.
Instance Attribute Details
#required_query_attributes ⇒ Object (readonly)
Returns the value of attribute required_query_attributes.
19 20 21 |
# File 'lib/required_query_attributes/model.rb', line 19 def required_query_attributes @required_query_attributes end |
Class Method Details
.extended(base) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/required_query_attributes/model.rb', line 21 def self.extended(base) # Attach our own RequiredQueryAttributes::Relation # to existing delegate factories base.instance_eval do @relation_delegate_cache.values.each do |klass| klass.include Relation end end end |
Instance Method Details
#require_query_attribute(attribute) ⇒ Object
Declare this in your model to enforce that the provided attribute must be used in at least one condition on SELECT statements.
Parameters:
-
name - Attribute to enforce presence in queries.
14 15 16 17 |
# File 'lib/required_query_attributes/model.rb', line 14 def require_query_attribute(attribute) @required_query_attributes ||= [] @required_query_attributes << attribute.to_s end |