Module: Brigit::Listable::ClassMethods
- Defined in:
- lib/brigit/listable.rb
Instance Method Summary collapse
Instance Method Details
#[](name) ⇒ Object
11 12 13 |
# File 'lib/brigit/listable.rb', line 11 def [](name) list.detect { |klass| klass.name == name } end |
#inherited(klass) ⇒ Object
15 16 17 |
# File 'lib/brigit/listable.rb', line 15 def inherited(klass) list << klass end |
#list ⇒ Object
19 20 21 |
# File 'lib/brigit/listable.rb', line 19 def list @list ||= [] end |
#listing ⇒ Object
23 24 25 26 27 |
# File 'lib/brigit/listable.rb', line 23 def listing list.map do |l| block_given? ? yield(l.name) : l.name end.join(', ') end |
#name ⇒ Object
29 30 31 |
# File 'lib/brigit/listable.rb', line 29 def name to_s.sub(/^(?:.+::)?(.+?)[A-Z][a-z]+$/, '\1').downcase end |