Class: EJSONExt::Encoders::DefaultType

Inherits:
Object
  • Object
show all
Defined in:
lib/ejson_ext/encoders/default_type.rb

Direct Known Subclasses

EscapeType, RecursiveType, TimeType, KeyValParser

Instance Method Summary collapse

Constructor Details

#initialize(key, value) ⇒ DefaultType

Returns a new instance of DefaultType.



4
5
6
7
# File 'lib/ejson_ext/encoders/default_type.rb', line 4

def initialize(key, value)
  @key = key
  @value = value
end

Instance Method Details

#handler?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/ejson_ext/encoders/default_type.rb', line 9

def handler?
  true
end

#next_handlerObject



13
14
15
# File 'lib/ejson_ext/encoders/default_type.rb', line 13

def next_handler
  @next_handler || DefaultType.new(key, value)
end

#next_handler=(handler) ⇒ Object



17
18
19
# File 'lib/ejson_ext/encoders/default_type.rb', line 17

def next_handler=(handler)
  @next_handler = handler
end

#parseObject



21
22
23
24
25
26
27
# File 'lib/ejson_ext/encoders/default_type.rb', line 21

def parse
  if handler?
    [key, value]
  else
    next_handler.parse
  end
end