Sha256: 8e15347ffabfa5e8a1eb6e6c89e471c1dc9b04ba29c0ec8ba61e956a4dba3ca8

Contents?: true

Size: 1.12 KB

Versions: 13

Compression:

Stored size: 1.12 KB

Contents

module SparkApi
  module Models
    class IdxLink < Base
      self.element_name="idxlinks"
      
      LINK_TYPES = ["QuickSearch", "SavedSearch", "MyListings", "Roster"]

      #TODO Work all below into common base class
      def self.find(*arguments)
        scope = arguments.slice!(0)
        options = arguments.slice!(0) || {}
        
        case scope
          when :all   then find_every(options)
          when :first then find_every(options).first
          when :last  then find_every(options).last
          when :one   then find_one(options)
          else             find_single(scope, options)
        end
      end
      
      def self.first(*arguments)
        find(:first, *arguments)
      end

      def self.last(*arguments)
        find(:last, *arguments)
      end

      private

      def self.find_every(options)
        raise NotImplementedError # TODO
      end

      def self.find_one(options)
        raise NotImplementedError # TODO
      end

      def self.find_single(scope, options)
        resp = SparkApi.client.get("/idxlinks/#{scope}", options)
        new(resp.first)
      end

    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
spark_api-1.3.6 lib/spark_api/models/idx_link.rb
spark_api-1.3.3 lib/spark_api/models/idx_link.rb
spark_api-1.3.1 lib/spark_api/models/idx_link.rb
spark_api-1.3.0 lib/spark_api/models/idx_link.rb
spark_api-1.2.1 lib/spark_api/models/idx_link.rb
spark_api-1.2.0 lib/spark_api/models/idx_link.rb
spark_api-1.1.2 lib/spark_api/models/idx_link.rb
spark_api-1.1.1 lib/spark_api/models/idx_link.rb
spark_api-1.1.0 lib/spark_api/models/idx_link.rb
spark_api-1.0.4 lib/spark_api/models/idx_link.rb
spark_api-1.0.2 lib/spark_api/models/idx_link.rb
spark_api-1.0.1 lib/spark_api/models/idx_link.rb
spark_api-1.0.0 lib/spark_api/models/idx_link.rb