Class: Cartoonist::Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/cartoonist.rb

Constant Summary collapse

@@all =
{}
@@cached_order =
[]
@@hooks =
[]

Class Method Summary collapse

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

.allObject



117
118
119
# File 'lib/cartoonist.rb', line 117

def all
  @@cached_order.map &:constantize
end

.hooksObject



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