Class: CollectionJson::Rack::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/collection_json/rack/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json_string) ⇒ Parser

Returns a new instance of Parser.



5
6
7
8
9
# File 'lib/collection_json/rack/parser.rb', line 5

def initialize json_string
  @json = JSON.parse json_string
rescue JSON::ParserError => e
  raise CollectionJson::InvalidJsonError.new "Couldn't parse: <#{json_string}>, #{e.message}"
end

Instance Attribute Details

#jsonObject (readonly)

Returns the value of attribute json.



3
4
5
# File 'lib/collection_json/rack/parser.rb', line 3

def json
  @json
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/collection_json/rack/parser.rb', line 11

def valid?
  false
end