Module: EagerGroup::ClassMethods
- Defined in:
- lib/eager_group.rb
Instance Attribute Summary collapse
-
#eager_group_definations ⇒ Object
readonly
Returns the value of attribute eager_group_definations.
Instance Method Summary collapse
-
#define_eager_group(attr, association, aggregate_function, column_name, scope = nil) ⇒ Object
class Post define_eager_group :comments_avergage_rating, :comments, :average, :rating define_eager_group :approved_comments_count, :comments, :count, :*, -> { approved } end.
Instance Attribute Details
#eager_group_definations ⇒ Object (readonly)
Returns the value of attribute eager_group_definations.
15 16 17 |
# File 'lib/eager_group.rb', line 15 def eager_group_definations @eager_group_definations end |
Instance Method Details
#define_eager_group(attr, association, aggregate_function, column_name, scope = nil) ⇒ Object
class Post
define_eager_group :comments_avergage_rating, :comments, :average, :rating
define_eager_group :approved_comments_count, :comments, :count, :*, -> { approved }
end
21 22 23 24 25 |
# File 'lib/eager_group.rb', line 21 def define_eager_group(attr, association, aggregate_function, column_name, scope = nil) self.send :attr_accessor, attr @eager_group_definations ||= {} @eager_group_definations[attr] = Definition.new association, aggregate_function, column_name, scope end |