Class: Fabricators::Fabricator
- Inherits:
-
Object
- Object
- Fabricators::Fabricator
- Defined in:
- lib/fabricators/fabricator.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#proxy ⇒ Object
readonly
Returns the value of attribute proxy.
Instance Method Summary collapse
- #attributes_for(options = {}) ⇒ Object
-
#initialize(name, options = {}, &block) ⇒ Fabricator
constructor
A new instance of Fabricator.
- #parent ⇒ Object
Constructor Details
#initialize(name, options = {}, &block) ⇒ Fabricator
Returns a new instance of Fabricator.
6 7 8 9 10 11 12 |
# File 'lib/fabricators/fabricator.rb', line 6 def initialize(name, ={}, &block) @name = name @options = @block = block @loaded = false Fetcher.new(name, , &block) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/fabricators/fabricator.rb', line 4 def @options end |
#proxy ⇒ Object (readonly)
Returns the value of attribute proxy.
4 5 6 |
# File 'lib/fabricators/fabricator.rb', line 4 def proxy @proxy end |
Instance Method Details
#attributes_for(options = {}) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/fabricators/fabricator.rb', line 22 def attributes_for(={}) {}.tap do |hash| iterate_attributes(, proxy) do |name, value| hash[name] = value end end end |
#parent ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/fabricators/fabricator.rb', line 14 def parent @parent ||= begin if @options[:parent] Fabricators.definitions.find(@options[:parent]) end end end |