Class: Cartoonist::Entity
- Inherits:
-
Object
- Object
- Cartoonist::Entity
- Defined in:
- lib/cartoonist.rb
Constant Summary collapse
- @@all =
{}
- @@cached_order =
[]
- @@hooks =
[]
Class Method Summary collapse
- .[](key) ⇒ Object
- .add(key, model_name) ⇒ Object
- .all ⇒ Object
- .hooks ⇒ Object
- .hooks_with(method) ⇒ Object
- .register_hooks(hooks) ⇒ Object
Class Method Details
.[](key) ⇒ Object
121 122 123 |
# File 'lib/cartoonist.rb', line 121 def [](key) @@all[key].constantize end |
.add(key, model_name) ⇒ Object
125 126 127 128 |
# File 'lib/cartoonist.rb', line 125 def add(key, model_name) @@all[key] = model_name @@cached_order = @@all.keys.sort.map { |key| @@all[key] } end |
.all ⇒ Object
117 118 119 |
# File 'lib/cartoonist.rb', line 117 def all @@cached_order.map &:constantize end |
.hooks ⇒ Object
134 135 136 |
# File 'lib/cartoonist.rb', line 134 def hooks @@hooks end |
.hooks_with(method) ⇒ Object
138 139 140 |
# File 'lib/cartoonist.rb', line 138 def hooks_with(method) @@hooks.select { |x| x.respond_to? method } end |
.register_hooks(hooks) ⇒ Object
130 131 132 |
# File 'lib/cartoonist.rb', line 130 def register_hooks(hooks) @@hooks << hooks unless @@hooks.include? hooks end |