Class: Blueprinter::ViewCollection Private

Inherits:
Object
  • Object
show all
Defined in:
lib/blueprinter/view_collection.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

#initializeViewCollection

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 ViewCollection.



5
6
7
8
9
10
# File 'lib/blueprinter/view_collection.rb', line 5

def initialize
  @views = {
    identifier: View.new(:identifier),
    default: View.new(:default)
  }
end

Instance Attribute Details

#viewsObject (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_collection.rb', line 4

def views
  @views
end

Instance Method Details

#[](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.



20
21
22
# File 'lib/blueprinter/view_collection.rb', line 20

def [](view_name)
  @views[view_name] ||= View.new(view_name)
end

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



16
17
18
# File 'lib/blueprinter/view_collection.rb', line 16

def fields_for(view_name)
  identifier_fields + sortable_fields(view_name).values.sort_by(&:name)
end

#has_view?(view_name) ⇒ Boolean

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:

  • (Boolean)


12
13
14
# File 'lib/blueprinter/view_collection.rb', line 12

def has_view?(view_name)
  views.has_key? view_name
end