Class: Blueprinter::Configuration Private

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

Constant Summary collapse

VALID_CALLABLES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

%i[if unless].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/blueprinter/configuration.rb', line 27

def initialize
  @deprecations = :stderror
  @association_default = nil
  @datetime_format = nil
  @field_default = nil
  @generator = JSON
  @if = nil
  @method = :generate
  @sort_fields_by = :name_asc
  @unless = nil
  @extractor_default = AutoExtractor
  @default_transformers = []
  @custom_array_like_classes = []
  @extensions = Extensions.new
end

Instance Attribute Details

#association_defaultObject

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.



9
10
11
# File 'lib/blueprinter/configuration.rb', line 9

def association_default
  @association_default
end

#custom_array_like_classesObject

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.



9
10
11
# File 'lib/blueprinter/configuration.rb', line 9

def custom_array_like_classes
  @custom_array_like_classes
end

#datetime_formatObject

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.



9
10
11
# File 'lib/blueprinter/configuration.rb', line 9

def datetime_format
  @datetime_format
end

#default_transformersObject

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.



9
10
11
# File 'lib/blueprinter/configuration.rb', line 9

def default_transformers
  @default_transformers
end

#deprecationsObject

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.



9
10
11
# File 'lib/blueprinter/configuration.rb', line 9

def deprecations
  @deprecations
end

#extensionsObject

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.



23
24
25
# File 'lib/blueprinter/configuration.rb', line 23

def extensions
  @extensions
end

#extractor_defaultObject

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.



9
10
11
# File 'lib/blueprinter/configuration.rb', line 9

def extractor_default
  @extractor_default
end

#field_defaultObject

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.



9
10
11
# File 'lib/blueprinter/configuration.rb', line 9

def field_default
  @field_default
end

#generatorObject

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.



9
10
11
# File 'lib/blueprinter/configuration.rb', line 9

def generator
  @generator
end

#ifObject

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.



9
10
11
# File 'lib/blueprinter/configuration.rb', line 9

def if
  @if
end

#methodObject

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.



9
10
11
# File 'lib/blueprinter/configuration.rb', line 9

def method
  @method
end

#sort_fields_byObject

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.



9
10
11
# File 'lib/blueprinter/configuration.rb', line 9

def sort_fields_by
  @sort_fields_by
end

#unlessObject

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.



9
10
11
# File 'lib/blueprinter/configuration.rb', line 9

def unless
  @unless
end

Instance Method Details

#array_like_classesObject

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.



47
48
49
50
51
52
53
# File 'lib/blueprinter/configuration.rb', line 47

def array_like_classes
  @_array_like_classes ||= [
    Array,
    defined?(ActiveRecord::Relation) && ActiveRecord::Relation,
    *custom_array_like_classes
  ].compact
end

#jsonify(blob) ⇒ 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.



55
56
57
# File 'lib/blueprinter/configuration.rb', line 55

def jsonify(blob)
  generator.public_send(method, blob)
end

#valid_callable?(callable_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)


59
60
61
# File 'lib/blueprinter/configuration.rb', line 59

def valid_callable?(callable_name)
  VALID_CALLABLES.include?(callable_name)
end