Sha256: bb5640802b006109587bc600b2c0910fe296fff6f7e71b8d36ca20053c6db614

Contents?: true

Size: 599 Bytes

Versions: 7

Compression:

Stored size: 599 Bytes

Contents

module NCore
  module FindSingle
    extend ActiveSupport::Concern

    module ClassMethods
      def find(params={})
        obj = new
        obj.reload(params)
      end

      def retrieve(params={})
        find params
      rescue module_parent::RecordNotFound
        nil
      end
    end

    def id
      'singleton'
    end

    def reload(find_params={})
      params = parse_request_params(find_params).reverse_merge credentials: api_creds
      parsed, @api_creds = request(:get, resource_path, params)
      @attribs = {}.with_indifferent_access
      load(parsed)
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ncore-3.12.0 lib/ncore/methods/find_single.rb
ncore-3.11.0 lib/ncore/methods/find_single.rb
ncore-3.10.0 lib/ncore/methods/find_single.rb
ncore-3.9.1 lib/ncore/methods/find_single.rb
ncore-3.9.0 lib/ncore/methods/find_single.rb
ncore-3.8.1 lib/ncore/methods/find_single.rb
ncore-3.8.0 lib/ncore/methods/find_single.rb