Exception: CouchDB::InvalidObject
- Defined in:
- lib/couchdb/errors.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(json_object) ⇒ InvalidObject
constructor
A new instance of InvalidObject.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(json_object) ⇒ InvalidObject
Returns a new instance of InvalidObject.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/couchdb/errors.rb', line 56 def initialize(json_object) @errors = json_object.errors.inject({}) { |h, (name, error)| h[name] = case error when PropertyError error.to_hash.tap { |hash| hash.delete :property } when InvalidObject error.to_hash else {:error => 'unknown'} end h } super "#{json_object.inspect} is invalid." end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
54 55 56 |
# File 'lib/couchdb/errors.rb', line 54 def errors @errors end |
Instance Method Details
#to_hash ⇒ Object
72 73 74 |
# File 'lib/couchdb/errors.rb', line 72 def to_hash @errors end |
#to_json ⇒ Object
76 77 78 |
# File 'lib/couchdb/errors.rb', line 76 def to_json JSON.fast_generate @errors end |