Class: Blueprinter::View Private
- Inherits:
-
Object
- Object
- Blueprinter::View
- Defined in:
- lib/blueprinter/view.rb
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.
Instance Attribute Summary collapse
- #excluded_field_names ⇒ Object readonly private
- #fields ⇒ Object readonly private
- #included_view_names ⇒ Object readonly private
- #name ⇒ Object readonly private
Instance Method Summary collapse
- #<<(field) ⇒ Object private
- #exclude_field(field_name) ⇒ Object private
- #exclude_fields(field_names) ⇒ Object private
- #include_view(view_name) ⇒ Object private
- #inherit(view) ⇒ Object private
-
#initialize(name, fields: {}, included_view_names: [], excluded_view_names: []) ⇒ View
constructor
private
A new instance of View.
Constructor Details
#initialize(name, fields: {}, included_view_names: [], excluded_view_names: []) ⇒ 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.
6 7 8 9 10 11 |
# File 'lib/blueprinter/view.rb', line 6 def initialize(name, fields: {}, included_view_names: [], excluded_view_names: []) @name = name @fields = fields @included_view_names = included_view_names @excluded_field_names = excluded_view_names end |
Instance Attribute Details
#excluded_field_names ⇒ 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.
4 5 6 |
# File 'lib/blueprinter/view.rb', line 4 def excluded_field_names @excluded_field_names end |
#fields ⇒ 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.
4 5 6 |
# File 'lib/blueprinter/view.rb', line 4 def fields @fields end |
#included_view_names ⇒ 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.
4 5 6 |
# File 'lib/blueprinter/view.rb', line 4 def included_view_names @included_view_names end |
#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.
4 5 6 |
# File 'lib/blueprinter/view.rb', line 4 def name @name end |
Instance Method Details
#<<(field) ⇒ Object
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.
41 42 43 |
# File 'lib/blueprinter/view.rb', line 41 def <<(field) fields[field.name] = field end |
#exclude_field(field_name) ⇒ Object
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.
31 32 33 |
# File 'lib/blueprinter/view.rb', line 31 def exclude_field(field_name) excluded_field_names << field_name end |
#exclude_fields(field_names) ⇒ Object
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 38 39 |
# File 'lib/blueprinter/view.rb', line 35 def exclude_fields(field_names) field_names.each do |field_name| excluded_field_names << field_name end end |
#include_view(view_name) ⇒ Object
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.
27 28 29 |
# File 'lib/blueprinter/view.rb', line 27 def include_view(view_name) included_view_names << view_name end |
#inherit(view) ⇒ Object
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.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/blueprinter/view.rb', line 13 def inherit(view) view.fields.values.each do |field| self << field end view.included_view_names.each do |view_name| include_view(view_name) end view.excluded_field_names.each do |field_name| exclude_field(field_name) end end |