Class: SimplePolicy::Entity
- Inherits:
-
Object
- Object
- SimplePolicy::Entity
- Defined in:
- lib/simple_policy/entity.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
- .applies_to?(object, options = {}, &block) ⇒ Boolean
- .applies_to_all?(collection, options = {}, &block) ⇒ Boolean
- .applies_to_any?(collection, options = {}, &block) ⇒ Boolean
- .call(*params, **options, &block) ⇒ Object
- .object_alias(name) ⇒ Object
Instance Method Summary collapse
-
#initialize(object, options, block) ⇒ Entity
constructor
A new instance of Entity.
Constructor Details
#initialize(object, options, block) ⇒ Entity
Returns a new instance of Entity.
7 8 9 10 11 |
# File 'lib/simple_policy/entity.rb', line 7 def initialize(object, , block) @object = object @options = @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
5 6 7 |
# File 'lib/simple_policy/entity.rb', line 5 def block @block end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
5 6 7 |
# File 'lib/simple_policy/entity.rb', line 5 def object @object end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/simple_policy/entity.rb', line 5 def @options end |
Class Method Details
.applies_to?(object, options = {}, &block) ⇒ Boolean
35 36 37 |
# File 'lib/simple_policy/entity.rb', line 35 def self.applies_to?(object, = {}, &block) call(object, , block) end |
.applies_to_all?(collection, options = {}, &block) ⇒ Boolean
23 24 25 26 27 |
# File 'lib/simple_policy/entity.rb', line 23 def self.applies_to_all?(collection, = {}, &block) collection.all? do |object| applies_to?(object, , &block) end end |
.applies_to_any?(collection, options = {}, &block) ⇒ Boolean
29 30 31 32 33 |
# File 'lib/simple_policy/entity.rb', line 29 def self.applies_to_any?(collection, = {}, &block) collection.any? do |object| applies_to?(object, , &block) end end |
.call(*params, **options, &block) ⇒ Object
13 14 15 |
# File 'lib/simple_policy/entity.rb', line 13 def self.call(*params, **, &block) new(*params, **).call(&block) end |
.object_alias(name) ⇒ Object
17 18 19 20 21 |
# File 'lib/simple_policy/entity.rb', line 17 def self.object_alias(name) define_method(name) do object end end |