Class: Blueprinter::Reflection::View Private
- Inherits:
-
Object
- Object
- Blueprinter::Reflection::View
- Defined in:
- lib/blueprinter/reflection.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Represents a view within a Blueprint.
Instance Attribute Summary collapse
- #name ⇒ Object readonly private
Instance Method Summary collapse
-
#associations ⇒ Hash<Symbol, Blueprinter::Reflection::Association>
private
Returns a Hash of associations in this view (recursive) keyed by method name.
-
#fields ⇒ Hash<Symbol, Blueprinter::Reflection::Field>
private
Returns a Hash of fields in this view (recursive) keyed by method name.
-
#initialize(name, view_collection) ⇒ View
constructor
private
A new instance of View.
Constructor Details
#initialize(name, view_collection) ⇒ View
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of View.
37 38 39 40 |
# File 'lib/blueprinter/reflection.rb', line 37 def initialize(name, view_collection) @name = name @view_collection = view_collection end |
Instance Attribute Details
#name ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
35 36 37 |
# File 'lib/blueprinter/reflection.rb', line 35 def name @name end |
Instance Method Details
#associations ⇒ Hash<Symbol, Blueprinter::Reflection::Association>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a Hash of associations in this view (recursive) keyed by method name.
60 61 62 63 64 65 66 67 68 |
# File 'lib/blueprinter/reflection.rb', line 60 def associations @associations ||= @view_collection.fields_for(name).each_with_object({}) do |field, obj| next unless field.[:association] blueprint = field..fetch(:blueprint) view = field.[:view] || :default obj[field.name] = Association.new(field.method, field.name, blueprint, view, field.) end end |
#fields ⇒ Hash<Symbol, Blueprinter::Reflection::Field>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a Hash of fields in this view (recursive) keyed by method name.
47 48 49 50 51 52 53 |
# File 'lib/blueprinter/reflection.rb', line 47 def fields @fields ||= @view_collection.fields_for(name).each_with_object({}) do |field, obj| next if field.[:association] obj[field.name] = Field.new(field.method, field.name, field.) end end |