Class: DisplayCase::EnumerableExhibit
- Inherits:
-
Exhibit
- Object
- SimpleDelegator
- Exhibit
- DisplayCase::EnumerableExhibit
show all
- Includes:
- Enumerable
- Defined in:
- lib/display_case/enumerable_exhibit.rb
Instance Attribute Summary
Attributes inherited from Exhibit
#context
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Exhibit
#__class__, #__instance_of__?, #__kind_of__?, #cache, #class, class_comparator, exhibit, #exhibit, #exhibit_chain, exhibit_if_applicable, #exhibited?, exhibited_object?, exhibits, inherited, #initialize, initialize_exhibits, #inspect, #inspect_exhibits, #instance_of?, #kind_of?
Class Method Details
.applicable_to?(object, context = nil) ⇒ Boolean
7
8
9
10
11
|
# File 'lib/display_case/enumerable_exhibit.rb', line 7
def self.applicable_to?(object, context=nil)
object.respond_to?(:each)
end
|
Instance Method Details
#each ⇒ Object
36
37
38
39
40
41
|
# File 'lib/display_case/enumerable_exhibit.rb', line 36
def each(*)
__getobj__.map do |e|
yield exhibit(e) if block_given?
exhibit(e)
end.each
end
|
#render(template, options = {}) ⇒ Object
54
55
56
57
58
|
# File 'lib/display_case/enumerable_exhibit.rb', line 54
def render(template, options = {})
inject(ActiveSupport::SafeBuffer.new) { |output,element|
output << element.render(template, options)
}
end
|
#to_ary ⇒ Object
‘render ’…‘, :collection => self` will call #to_ary on this before rendering, so we need to be prepared.
45
46
47
|
# File 'lib/display_case/enumerable_exhibit.rb', line 45
def to_ary
self.to_a
end
|
#to_json(*args) ⇒ Object
50
51
52
|
# File 'lib/display_case/enumerable_exhibit.rb', line 50
def to_json(*args)
as_json(*args).to_json(*args)
end
|