Sha256: 87b9e50c8c7906c16cb62aa42283061f5b309367901d54e1254d7624a94b9c41

Contents?: true

Size: 725 Bytes

Versions: 19

Compression:

Stored size: 725 Bytes

Contents

module NCore
  module Find
    extend ActiveSupport::Concern

    module ClassMethods
      def find(id, params={})
        raise(parent::RecordNotFound, "Cannot find id=nil") if id.blank?
        params = parse_request_params(params)
        o = new({id: id}, params[:credentials])
        o.reload(params)
      end

      def retrieve(id, params={})
        find id, params
      rescue parent::RecordNotFound
        false
      end
    end

    def reload(find_params={})
      return if id.blank?
      params = parse_request_params(find_params).reverse_merge credentials: api_creds
      parsed, @api_creds = request(:get, url, params)
      @attribs = {}.with_indifferent_access
      load(parsed)
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ncore-2.3.3 lib/ncore/methods/find.rb
ncore-2.3.2 lib/ncore/methods/find.rb
ncore-2.3.1 lib/ncore/methods/find.rb
ncore-2.3.0 lib/ncore/methods/find.rb
ncore-2.2.2 lib/ncore/methods/find.rb
ncore-2.2.1 lib/ncore/methods/find.rb
ncore-2.2.0 lib/ncore/methods/find.rb
ncore-2.1.2 lib/ncore/methods/find.rb
ncore-2.1.1 lib/ncore/methods/find.rb
ncore-2.1.0 lib/ncore/methods/find.rb
ncore-2.0.8 lib/ncore/methods/find.rb
ncore-2.0.7 lib/ncore/methods/find.rb
ncore-2.0.6 lib/ncore/methods/find.rb
ncore-2.0.5 lib/ncore/methods/find.rb
ncore-2.0.4 lib/ncore/methods/find.rb
ncore-2.0.3 lib/ncore/methods/find.rb
ncore-2.0.2 lib/ncore/methods/find.rb
ncore-2.0.1 lib/ncore/methods/find.rb
ncore-2.0.0 lib/ncore/methods/find.rb