Class: ActiveSupport::JSON::Encoding::Encoder

Inherits:
Object
  • Object
show all
Defined in:
activesupport/lib/active_support/json/encoding.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) ⇒ Encoder



39
40
41
42
# File 'activesupport/lib/active_support/json/encoding.rb', line 39

def initialize(options = nil)
  @options = options
  @seen = []
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options



37
38
39
# File 'activesupport/lib/active_support/json/encoding.rb', line 37

def options
  @options
end

Instance Method Details

#encode(value) ⇒ Object



44
45
46
47
48
# File 'activesupport/lib/active_support/json/encoding.rb', line 44

def encode(value)
  check_for_circular_references(value) do
    value.as_json(options).encode_json(self)
  end
end

#escape(string) ⇒ Object



50
51
52
# File 'activesupport/lib/active_support/json/encoding.rb', line 50

def escape(string)
  Encoding.escape(string)
end