require "openlogi/errors"

module Openlogi
  class BaseObject < Hashie::Dash
    include Hashie::Extensions::Dash::Coercion
    include Hashie::Extensions::MergeInitializer
    include Hashie::Extensions::IndifferentAccess

    def initialize(attributes = {}, &block)
      @attributes = attributes.to_hash.dup
      @attributes.each_key do |key|
        if !self.class.property?(key)
          @attributes.delete(key)
          warn "#{key} is not a property of #{self.class} and will be ignored."
        end
      end

      super(@attributes, &block)
    end

    property :error, coerce: String
    property :errors, coerce: Openlogi::Errors
    property :error_description, coerce: String

    def valid?
      error.nil? && (errors.nil? || errors.empty?)
    end
  end
end

require "openlogi/errors"

module Openlogi
  class BaseObject < Hashie::Dash
    include Hashie::Extensions::Dash::Coercion
    include Hashie::Extensions::MergeInitializer
    include Hashie::Extensions::IndifferentAccess

    def initialize(attributes = {}, &block)
      @attributes = attributes.to_hash.dup
      @attributes.each_key do |key|
        if !self.class.property?(key)
          @attributes.delete(key)
          warn "#{key} is not a property of #{self.class} and will be ignored."
        end
      end

      super(@attributes, &block)
    end

    property :error
    property :errors, coerce: Openlogi::Errors
    property :error_description

    def valid?
      error.nil? && (errors.nil? || errors.empty?)
    end
  end
end

--- 
+++ 
@@ -18,9 +18,9 @@
       super(@attributes, &block)
     end
 
-    property :error
+    property :error, coerce: String
     property :errors, coerce: Openlogi::Errors
-    property :error_description
+    property :error_description, coerce: String
 
     def valid?
       error.nil? && (errors.nil? || errors.empty?)
Add missing coercions to error-related properties on base object
