Sha256: 87ff1cd49c506a596e878f00d9f16b80b16a554aa7c3f99adac44ed7c8b9794b

Contents?: true

Size: 875 Bytes

Versions: 3

Compression:

Stored size: 875 Bytes

Contents

module Quandl
module Client
module Concerns
  
module Properties
  extend ActiveSupport::Concern

  included do

    include Her::Model
    use_api Client.her_api
  
    before_save :halt_unless_valid!
    
    def valid_with_server?
      return false unless valid?
      return false unless errors_params.blank?
      return false unless errors_server.blank?
      true
    end
    
    def error_messages
      valid?
      errors_client.deep_merge(errors_server).deep_merge(errors_params)
    end
    
    def errors_client
      errors.messages || {}
    end
    
    def errors_server
      self.attributes[:errors] || {}
    end
    
    def errors_params
      response_errors.present? ? { response_errors: response_errors } : {}
    end
    
    
    protected
  
    def halt_unless_valid!
      return false unless valid?
    end
    
  end      
end

end
end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
quandl_client-0.0.12 lib/quandl/client/concerns/properties.rb
quandl_client-0.0.11 lib/quandl/client/concerns/properties.rb
quandl_client-0.0.10 lib/quandl/client/concerns/properties.rb