Module: JSONDecoder::Node

Defined in:
lib/motion_json_decoder/node.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/motion_json_decoder/node.rb', line 12

def method_missing(meth, *args, &block)
  if meth.to_s =~ /^(.+)?$/
    field_name = meth.to_s.gsub('?', '')
    json.has_key? field_name
  else
    super
  end
end

Class Method Details

.included(base) ⇒ Object



8
9
10
# File 'lib/motion_json_decoder/node.rb', line 8

def self.included(base)
  base.send :extend, ClassMethods
end

Instance Method Details

#initialize(json) ⇒ Object



4
5
6
# File 'lib/motion_json_decoder/node.rb', line 4

def initialize(json)
  self.json = json
end


50
51
52
# File 'lib/motion_json_decoder/node.rb', line 50

def links
  json[:_links]
end