Sha256: f35997d48d3d935e8cd8d59026ace42d7602ef031b6ef4d21b1fb22acff28976

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

module FlexmlsApi
  module Models
    class IdxLink < Base
      self.element_name="idxlinks"

      #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 = FlexmlsApi.client.get("/idxlinks/#{scope}", options)
        new(resp[0])
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flexmls_api-0.3.3 lib/flexmls_api/models/idx_link.rb
flexmls_api-0.3.2 lib/flexmls_api/models/idx_link.rb