Class: GroupConfigurator
- Inherits:
-
Object
- Object
- GroupConfigurator
- Defined in:
- lib/slimer/group_configurator.rb
Overview
A simple utility class to parse nested groups
Instance Attribute Summary collapse
-
#groups ⇒ Object
(also: #all)
readonly
Returns the value of attribute groups.
Class Method Summary collapse
-
.group(new_groups, &block) ⇒ Object
Creates a flat set of groups from a string or block.
Instance Method Summary collapse
-
#group(new_group) {|_self| ... } ⇒ Object
Creates a flat set of groups from a string or block.
Instance Attribute Details
#groups ⇒ Object (readonly) Also known as: all
Returns the value of attribute groups.
5 6 7 |
# File 'lib/slimer/group_configurator.rb', line 5 def groups @groups end |
Class Method Details
.group(new_groups, &block) ⇒ Object
Creates a flat set of groups from a string or block
GroupConfigurator.group(“ruby/rails”) => #<Set: “ruby”, “ruby/rails” ] > GroupConfigurator.group(:ruby) do |config|
config.group :rails
end => #<Set: “ruby”, “ruby/rails” ] >
17 18 19 |
# File 'lib/slimer/group_configurator.rb', line 17 def self.group(new_groups, &block) new.group(new_groups, &block) end |
Instance Method Details
#group(new_group) {|_self| ... } ⇒ Object
Creates a flat set of groups from a string or block
GroupConfigurator.group(“ruby/rails”) => #<Set: “ruby”, “ruby/rails” ] > GroupConfigurator.group(:ruby) do |config|
config.group :rails
end => #<Set: “ruby”, “ruby/rails” ] >
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/slimer/group_configurator.rb', line 29 def group(new_group) @groups ||= Set.new return group(group_from_string(new_group)) if new_group.to_s.include?("/") group_with_level = [@level, new_group].compact.join("/") @groups << group_with_level return self unless block_given? @level = group_with_level yield(self) self end |