Class: Azeroth::Decorator::KeyValueExtractor Private

Inherits:
Sinclair::Model
  • Object
show all
Defined in:
lib/azeroth/decorator/key_value_extractor.rb

Overview

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.

Class responsible to extract the value for an attribute

The value is extracted by sending a method call to the decorator

A decorator is infered for the value / attribute or used from the options given

Instance Method Summary collapse

Instance Method Details

#as_jsonHash

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.

Return hash for attribute

Returns:

  • (Hash)

    hash in the format { attribute => decorated_value }



27
28
29
30
31
32
33
34
35
# File 'lib/azeroth/decorator/key_value_extractor.rb', line 27

def as_json
  return {} unless add_attribute?

  key = options.as || attribute

  {
    key.to_s => json_value
  }
end