Class: Praxis::CollectionView
- Inherits:
-
View
- Object
- View
- Praxis::CollectionView
show all
- Defined in:
- lib/praxis-blueprints/collection_view.rb
Instance Attribute Summary
Attributes inherited from View
#name, #options, #schema
Instance Method Summary
collapse
Methods inherited from View
#attribute, #expanded_fields, #render
Constructor Details
#initialize(name, schema, member_view = nil) ⇒ CollectionView
Returns a new instance of CollectionView.
4
5
6
7
8
|
# File 'lib/praxis-blueprints/collection_view.rb', line 4
def initialize(name, schema, member_view = nil)
super(name, schema)
@_lazy_view = member_view if member_view
end
|
Instance Method Details
#contents ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/praxis-blueprints/collection_view.rb', line 10
def contents
if @_lazy_view
@contents = @_lazy_view.contents.clone
@_lazy_view = nil
end
super
end
|
#describe ⇒ Object
29
30
31
|
# File 'lib/praxis-blueprints/collection_view.rb', line 29
def describe
super.merge(type: :collection)
end
|
#example(context = Attributor::DEFAULT_ROOT_CONTEXT) ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/praxis-blueprints/collection_view.rb', line 18
def example(context = Attributor::DEFAULT_ROOT_CONTEXT)
collection = Array.new(3) do |i|
subcontext = context + ["at(#{i})"]
schema.example(subcontext)
end
opts = {}
opts[:context] = context if context
render(collection, **opts)
end
|