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
- #transformers ⇒ Object readonly private
Instance Method Summary collapse
- #<<(field) ⇒ Object private
- #add_transformer(custom_transformer) ⇒ Object private
- #exclude_field(field_name) ⇒ Object private
- #exclude_fields(field_names) ⇒ Object private
- #include_view(view_name) ⇒ Object private
- #include_views(view_names) ⇒ Object private
- #inherit(view) ⇒ Object private
-
#initialize(name, fields: {}, included_view_names: [], excluded_view_names: [], transformers: []) ⇒ View
constructor
private
A new instance of View.
Constructor Details
#initialize(name, fields: {}, included_view_names: [], excluded_view_names: [], transformers: []) ⇒ 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 12 |
# File 'lib/blueprinter/view.rb', line 6 def initialize(name, fields: {}, included_view_names: [], excluded_view_names: [],transformers: []) @name = name @fields = fields @included_view_names = included_view_names @excluded_field_names = excluded_view_names @transformers = transformers 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 |
#transformers ⇒ 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 transformers @transformers 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.
56 57 58 |
# File 'lib/blueprinter/view.rb', line 56 def <<(field) fields[field.name] = field end |
#add_transformer(custom_transformer) ⇒ 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.
52 53 54 |
# File 'lib/blueprinter/view.rb', line 52 def add_transformer(custom_transformer) transformers << custom_transformer 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.
42 43 44 |
# File 'lib/blueprinter/view.rb', line 42 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.
46 47 48 49 50 |
# File 'lib/blueprinter/view.rb', line 46 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.
32 33 34 |
# File 'lib/blueprinter/view.rb', line 32 def include_view(view_name) included_view_names << view_name end |
#include_views(view_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.
36 37 38 39 40 |
# File 'lib/blueprinter/view.rb', line 36 def include_views(view_names) view_names.each do |view_name| included_view_names << view_name end 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.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/blueprinter/view.rb', line 14 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 view.transformers.each do |transformer| self.add_transformer(transformer) end end |