Class: JsFixtures::Base
- Inherits:
-
Object
- Object
- JsFixtures::Base
- Defined in:
- lib/js_fixtures/base.rb
Direct Known Subclasses
Constant Summary collapse
- @@fixtures =
[]
- @@fixture_types =
[]
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
- .config(type, &block) ⇒ Object
- .create(name, config, &block) ⇒ Object
- .generate_all ⇒ Object
- .get(name) ⇒ Object
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
63 64 65 |
# File 'lib/js_fixtures/base.rb', line 63 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
64 65 66 |
# File 'lib/js_fixtures/base.rb', line 64 def name @name end |
Class Method Details
.config(type, &block) ⇒ Object
7 8 9 |
# File 'lib/js_fixtures/base.rb', line 7 def config(type, &block) block.call(get_by_type(type)) end |
.create(name, config, &block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/js_fixtures/base.rb', line 11 def create(name, config, &block) if config[:type] @@fixtures << create_p(config[:type], name, config) elsif config[:parent] fixture = get_by_name(config[:parent]).clone(name) @@fixtures << fixture else raise "need either :parent or :type to create fixture" end block.call(@@fixtures.last) end |
.generate_all ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/js_fixtures/base.rb', line 24 def generate_all workers = [] @@fixtures.flatten.each do |f| workers << Thread.new { f.generate() } end workers.each { |w| w.join } end |
.get(name) ⇒ Object
33 34 35 |
# File 'lib/js_fixtures/base.rb', line 33 def get(name) get_by_name(name).location end |