Module: Smelter::Extendable::ClassMethods

Defined in:
lib/smelter/extendable.rb

Instance Method Summary collapse

Instance Method Details

#define(extension_id, &block) ⇒ Object



46
47
48
49
# File 'lib/smelter/extendable.rb', line 46

def define(extension_id, &block)
  definition_proxy = DefinitionProxy.new(extension_id)
  definition_proxy.instance_eval(&block)
end

#register(extension_id, &block) ⇒ Object



41
42
43
44
# File 'lib/smelter/extendable.rb', line 41

def register(extension_id, &block)
  @registry ||= ThreadSafe::Cache.new
  @registry[extension_id.to_s] = block
end

#register_allObject



30
31
32
33
34
35
# File 'lib/smelter/extendable.rb', line 30

def register_all
  self.find_each do |extension|
    next if registry[extension.id]
    extension.register
  end
end

#registryObject



37
38
39
# File 'lib/smelter/extendable.rb', line 37

def registry
  @registry ||= ThreadSafe::Cache.new
end