Class: Bastet::Group
- Inherits:
-
Object
- Object
- Bastet::Group
- Defined in:
- lib/bastet/group.rb
Instance Attribute Summary collapse
-
#criteria ⇒ Object
Returns the value of attribute criteria.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #contains?(entity) ⇒ Boolean
-
#initialize(name, &block) ⇒ Group
constructor
A new instance of Group.
Constructor Details
#initialize(name, &block) ⇒ Group
Returns a new instance of Group.
4 5 6 7 8 9 10 11 12 |
# File 'lib/bastet/group.rb', line 4 def initialize name, &block raise ArgumentError.new("Need to pass a criteria") unless block_given? validate_name!(name.to_s) @name = name.to_s @criteria = block persist! end |
Instance Attribute Details
#criteria ⇒ Object
Returns the value of attribute criteria.
2 3 4 |
# File 'lib/bastet/group.rb', line 2 def criteria @criteria end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/bastet/group.rb', line 2 def name @name end |
Class Method Details
Instance Method Details
#contains?(entity) ⇒ Boolean
18 19 20 |
# File 'lib/bastet/group.rb', line 18 def contains? entity criteria.call(entity) rescue false end |