class Fabrication::Schematic::Manager
Public Instance Methods
[](name)
click to toggle source
# File lib/fabrication/schematic/manager.rb, line 39 def [](name) schematics[name.to_sym] end
build_stack()
click to toggle source
# File lib/fabrication/schematic/manager.rb, line 47 def build_stack @build_stack ||= [] end
clear()
click to toggle source
# File lib/fabrication/schematic/manager.rb, line 21 def clear schematics.clear end
create_stack()
click to toggle source
# File lib/fabrication/schematic/manager.rb, line 43 def create_stack @create_stack ||= [] end
empty?()
click to toggle source
# File lib/fabrication/schematic/manager.rb, line 25 def empty? schematics.empty? end
freeze()
click to toggle source
# File lib/fabrication/schematic/manager.rb, line 29 def freeze @initializing = false end
initializing?()
click to toggle source
# File lib/fabrication/schematic/manager.rb, line 13 def initializing? @initializing ||= nil end
load_definitions()
click to toggle source
# File lib/fabrication/schematic/manager.rb, line 55 def load_definitions preinitialize Fabrication::Config.path_prefixes.each do |prefix| Fabrication::Config.fabricator_paths.each do |path| if File.file?(path) load path else Dir.glob(File.join(prefix.to_s, path, '**', '*.rb')).each do |file| load file end end end end ensure freeze end
preinitialize()
click to toggle source
# File lib/fabrication/schematic/manager.rb, line 8 def preinitialize @initializing = true clear end
prevent_recursion!()
click to toggle source
# File lib/fabrication/schematic/manager.rb, line 72 def prevent_recursion! (create_stack + build_stack + to_params_stack).group_by(&:to_sym).each do |name, values| raise Fabrication::InfiniteRecursionError, name if values.length > Fabrication::Config.recursion_limit end end
register(name, options, &block)
click to toggle source
# File lib/fabrication/schematic/manager.rb, line 33 def register(name, options, &block) name = name.to_sym raise_if_registered(name) store(name, Array(options.delete(:aliases)), options, &block) end
schematics()
click to toggle source
# File lib/fabrication/schematic/manager.rb, line 17 def schematics @schematics ||= {} end
to_params_stack()
click to toggle source
# File lib/fabrication/schematic/manager.rb, line 51 def to_params_stack @to_params_stack ||= [] end
Protected Instance Methods
raise_if_registered(name)
click to toggle source
# File lib/fabrication/schematic/manager.rb, line 80 def raise_if_registered(name) (raise Fabrication::DuplicateFabricatorError, name) if self[name] end
store(name, aliases, options, &block)
click to toggle source
# File lib/fabrication/schematic/manager.rb, line 84 def store(name, aliases, options, &block) schematic = schematics[name] = Fabrication::Schematic::Definition.new(name, options, &block) aliases.each { |as| schematics[as.to_sym] = schematic } end