Class: ViewSpec::Entry
- Inherits:
-
Object
show all
- Defined in:
- lib/view_spec/entry.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(subject, parent, context_defaults = {}, &block) ⇒ Entry
Returns a new instance of Entry.
5
6
7
8
9
10
11
|
# File 'lib/view_spec/entry.rb', line 5
def initialize(subject, parent, context_defaults = {}, &block)
@context_defaults = context_defaults.to_h
@subject = Subject.new(subject)
@parent = parent
context.instance_exec(&block) if block
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
43
44
45
|
# File 'lib/view_spec/entry.rb', line 43
def method_missing(name, ...)
context.respond_to?(name, true) ? context.send(name, ...) : super
end
|
Class Method Details
.type ⇒ Object
57
58
59
|
# File 'lib/view_spec/entry.rb', line 57
def type
@type ||= name.demodulize.underscore.to_sym
end
|
Instance Method Details
#respond_to_missing?(name, include_private = false) ⇒ Boolean
39
40
41
|
# File 'lib/view_spec/entry.rb', line 39
def respond_to_missing?(name, include_private = false)
context.respond_to?(name, true) || super
end
|
#short_identifier ⇒ Object
Also known as:
name
21
22
23
|
# File 'lib/view_spec/entry.rb', line 21
def short_identifier
@subject.to_short_identifier
end
|
#source_file ⇒ Object
31
32
33
|
# File 'lib/view_spec/entry.rb', line 31
def source_file
spec.source_file
end
|
#spec ⇒ Object
27
28
29
|
# File 'lib/view_spec/entry.rb', line 27
def spec
@parent ? @parent.spec : self
end
|
#title ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/view_spec/entry.rb', line 13
def title
if context.respond_to?(:title)
context.title || @subject.to_title
else
@subject.to_title
end
end
|
#to_partial_path ⇒ Object
35
36
37
|
# File 'lib/view_spec/entry.rb', line 35
def to_partial_path
"view_specs/#{type}"
end
|