Class: Shaf::Spec::Fixture
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
add, clear, collection
Constructor Details
#initialize(name, block) ⇒ Fixture
Returns a new instance of Fixture.
17
18
19
20
|
# File 'lib/shaf/spec/fixture.rb', line 17
def initialize(name, block)
@name = name
@block = block
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
35
36
37
38
|
# File 'lib/shaf/spec/fixture.rb', line 35
def method_missing(method, *args, &block)
return super unless resource_name?(args.size, block_given?)
add_entry(method, args.first, &block)
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
10
11
12
|
# File 'lib/shaf/spec/fixture.rb', line 10
def name
@name
end
|
Class Method Details
.define(name, &block) ⇒ Object
12
13
14
15
|
# File 'lib/shaf/spec/fixture.rb', line 12
def self.define(name, &block)
return unless block_given?
Fixtures.fixture_defined new(name.to_sym, block)
end
|
Instance Method Details
#add_entry(entry_name, resrc = nil, &block) ⇒ Object
27
28
29
30
31
|
# File 'lib/shaf/spec/fixture.rb', line 27
def add_entry(entry_name, resrc = nil, &block)
value = block ? instance_exec(&block) : resrc
fixtures = send(name)
fixtures[entry_name] = value
end
|
#init ⇒ Object
22
23
24
25
|
# File 'lib/shaf/spec/fixture.rb', line 22
def init
instance_exec(&@block)
self
end
|