Class: Blueprinter::Field Private

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

Direct Known Subclasses

Association

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, name, extractor, blueprint, options = {}) ⇒ Field

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



8
9
10
11
12
13
14
# File 'lib/blueprinter/field.rb', line 8

def initialize(method, name, extractor, blueprint, options = {})
  @method = method
  @name = name
  @extractor = extractor
  @blueprint = blueprint
  @options = options
end

Instance Attribute Details

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



6
7
8
# File 'lib/blueprinter/field.rb', line 6

def blueprint
  @blueprint
end

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



6
7
8
# File 'lib/blueprinter/field.rb', line 6

def extractor
  @extractor
end

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



6
7
8
# File 'lib/blueprinter/field.rb', line 6

def method
  @method
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.



6
7
8
# File 'lib/blueprinter/field.rb', line 6

def name
  @name
end

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



6
7
8
# File 'lib/blueprinter/field.rb', line 6

def options
  @options
end

Instance Method Details

#extract(object, local_options) ⇒ 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/field.rb', line 16

def extract(object, local_options)
  extractor.extract(method, object, local_options, options)
end

#skip?(field_name, object, local_options) ⇒ 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)


20
21
22
23
24
# File 'lib/blueprinter/field.rb', line 20

def skip?(field_name, object, local_options)
  return true if if_callable && !if_callable.call(field_name, object, local_options)

  unless_callable && unless_callable.call(field_name, object, local_options)
end