Class: Toni::PermissionMatcher
- Inherits:
-
Object
- Object
- Toni::PermissionMatcher
- Defined in:
- lib/toni/permission_matcher.rb
Defined Under Namespace
Classes: NotMatcher, PermittedToMatcher
Instance Attribute Summary collapse
-
#is_attr ⇒ Object
readonly
Returns the value of attribute is_attr.
-
#matcher ⇒ Object
readonly
Returns the value of attribute matcher.
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
Instance Method Summary collapse
-
#initialize(method_name, matcher, is_attr = false) ⇒ PermissionMatcher
constructor
A new instance of PermissionMatcher.
- #matches?(object) ⇒ Boolean
Constructor Details
#initialize(method_name, matcher, is_attr = false) ⇒ PermissionMatcher
Returns a new instance of PermissionMatcher.
6 7 8 9 10 |
# File 'lib/toni/permission_matcher.rb', line 6 def initialize(method_name, matcher, is_attr = false) @method_name = method_name @matcher = matcher @is_attr = is_attr end |
Instance Attribute Details
#is_attr ⇒ Object (readonly)
Returns the value of attribute is_attr.
4 5 6 |
# File 'lib/toni/permission_matcher.rb', line 4 def is_attr @is_attr end |
#matcher ⇒ Object (readonly)
Returns the value of attribute matcher.
4 5 6 |
# File 'lib/toni/permission_matcher.rb', line 4 def matcher @matcher end |
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
4 5 6 |
# File 'lib/toni/permission_matcher.rb', line 4 def method_name @method_name end |
Instance Method Details
#matches?(object) ⇒ Boolean
12 13 14 15 16 17 |
# File 'lib/toni/permission_matcher.rb', line 12 def matches?(object) unless object.respond_to?(method_name) raise Toni::NoMethodForMatcherError.new("#{method_name} is not defined for #{object.inspect}") end matcher.matches?(object.send(method_name)) end |