Exception: CouchDB::InvalidObject

Inherits:
Error
  • Object
show all
Defined in:
lib/couchdb/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#errorsObject (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_hashObject



72
73
74
# File 'lib/couchdb/errors.rb', line 72

def to_hash
  @errors
end

#to_jsonObject



76
77
78
# File 'lib/couchdb/errors.rb', line 76

def to_json
  JSON.fast_generate @errors
end