Class: Policier::ScopeUnion
- Inherits:
-
Object
- Object
- Policier::ScopeUnion
- Defined in:
- lib/policier/scope_union.rb
Instance Attribute Summary collapse
-
#relation ⇒ Object
readonly
Returns the value of attribute relation.
Instance Method Summary collapse
- #can?(method) ⇒ Boolean
- #exec(method) ⇒ Object
-
#initialize(model = nil) ⇒ ScopeUnion
constructor
A new instance of ScopeUnion.
- #payload ⇒ Object
- #scope(update) ⇒ Object
- #view ⇒ Object
- #visible? ⇒ Boolean
Constructor Details
#initialize(model = nil) ⇒ ScopeUnion
Returns a new instance of ScopeUnion.
7 8 9 10 11 12 13 |
# File 'lib/policier/scope_union.rb', line 7 def initialize(model = nil) @context = Context.current @model = model @relation = model.none if model.present? @visible = false @allowed_methods = Set.new end |
Instance Attribute Details
#relation ⇒ Object (readonly)
Returns the value of attribute relation.
5 6 7 |
# File 'lib/policier/scope_union.rb', line 5 def relation @relation end |
Instance Method Details
#can?(method) ⇒ Boolean
15 16 17 |
# File 'lib/policier/scope_union.rb', line 15 def can?(method) @allowed_methods.include?(method) end |
#exec(method) ⇒ Object
31 32 33 |
# File 'lib/policier/scope_union.rb', line 31 def exec(method) @allowed_methods.add(method) end |
#payload ⇒ Object
35 36 37 |
# File 'lib/policier/scope_union.rb', line 35 def payload @context.payload end |
#scope(update) ⇒ Object
27 28 29 |
# File 'lib/policier/scope_union.rb', line 27 def scope(update) @relation = @relation.or(update) end |
#view ⇒ Object
23 24 25 |
# File 'lib/policier/scope_union.rb', line 23 def view @visible = true end |
#visible? ⇒ Boolean
19 20 21 |
# File 'lib/policier/scope_union.rb', line 19 def visible? @visible end |