Module: GroupedModel
- Defined in:
- lib/grouped_model.rb
Defined Under Namespace
Modules: ClassMethods, GroupedInstanceMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
Grouped Models are those that can be assigned to one or more groups, and so made invisible to any reader who is not a member of one of those groups.
Class Method Details
.included(base) ⇒ Object
Grouped Models are those that can be assigned to one or more groups, and so made invisible to any reader who is not a member of one of those groups. As standard this is applied to pages and messages. To group-limit another class:
class Widget < ActiveRecord::Base
has_groups
...
This will define several class and instance methods and some scopes, most usefully:
Widget#groups -> groups association can << and +/- in the usual ways Group#widgets -> a scope, not an association Widget#visible_to?(reader) -> boolean Widget.visible_to(reader) -> list of visible widgets (as scope) Widget.belonging_to(group) -> list of widgets
The situation is more complex than it seems because of polymorphy and group-inheritance but that should all be taken care of for you.
21 22 23 |
# File 'lib/grouped_model.rb', line 21 def self.included(base) base.extend ClassMethods end |