Module: Shaf::Spec::Fixtures::Accessors
- Included in:
- Base, Shaf::Spec::Fixture
- Defined in:
- lib/shaf/spec/fixtures.rb
Class Method Summary collapse
Class Method Details
.add(name) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/shaf/spec/fixtures.rb', line 85 def add(name) collection = collection(name) return if instance_methods.include? name define_method(name) do |arg = nil| Fixtures.init_fixture(name) unless Fixtures.initialized? name if arg.nil? collection elsif collection.key? arg collection[arg] else raise FixtureNotFound.new(name, arg) end end end |
.clear(name) ⇒ Object
81 82 83 |
# File 'lib/shaf/spec/fixtures.rb', line 81 def clear(name) collection(name).clear end |
.collection(name) ⇒ Object
76 77 78 79 |
# File 'lib/shaf/spec/fixtures.rb', line 76 def collection(name) @collections ||= {} @collections[name] ||= {} end |