Class: JsonUpdater::JsonTypeDetector

Inherits:
Object
  • Object
show all
Defined in:
lib/json_updater/json_type_detector.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json_changeable) ⇒ JsonTypeDetector

Returns a new instance of JsonTypeDetector.



11
12
13
# File 'lib/json_updater/json_type_detector.rb', line 11

def initialize(json_changeable)
  @json_changeable = json_changeable
end

Instance Attribute Details

#json_changeableObject (readonly)

Returns the value of attribute json_changeable.



5
6
7
# File 'lib/json_updater/json_type_detector.rb', line 5

def json_changeable
  @json_changeable
end

Class Method Details

.detect_type(json_changeable) ⇒ Object



7
8
9
# File 'lib/json_updater/json_type_detector.rb', line 7

def self.detect_type(json_changeable)
  new(json_changeable).detect_type
end

Instance Method Details

#detect_typeObject



15
16
17
18
19
20
21
# File 'lib/json_updater/json_type_detector.rb', line 15

def detect_type
  if one_level_json?
    JsonUpdater::OneLevelJsonBuilder
  elsif one_level_json_array?
    JsonUpdater::OneLevelJsonArrayBuilder
  end
end