Class: Blueprinter::View Private

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_namesObject (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

#fieldsObject (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_namesObject (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

#nameObject (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.



21
22
23
24
25
26
27
# File 'lib/blueprinter/view.rb', line 21

def <<(field)
  if fields.has_key?(field.name)
    raise BlueprinterError,
      "Field #{field.name} already defined on #{name}"
  end
  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.



17
18
19
# File 'lib/blueprinter/view.rb', line 17

def exclude_field(field_name)
  excluded_field_names << field_name
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.



13
14
15
# File 'lib/blueprinter/view.rb', line 13

def include_view(view_name)
  included_view_names << view_name
end