Sha256: ecb1e671ed5b5dcbc2ce07e824f235bc39c6cd8d40435b03437bce83c983ff4e

Contents?: true

Size: 582 Bytes

Versions: 2

Compression:

Stored size: 582 Bytes

Contents

module VzaarApi
  module Lib
    module HasResourceUrl

      def self.included(base)
        base.include(InstanceMethods)
        base.extend(ClassMethods)
      end

      module InstanceMethods
        def resource_url(path = nil, scope_id = nil)
          self.class.resource_url(path, scope_id)
        end
      end

      module ClassMethods
        def resource_url(path=nil, scope_id=nil)
          ep = self::ENDPOINT
          args = ep.is_a?(Proc) ? [ep.call(scope_id, path), nil] : [ep, path]

          Api.resource_url *args
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vzaar_api-2.0.2 lib/vzaar_api/lib/has_resource_url.rb
vzaar_api-2.0.1 lib/vzaar_api/lib/has_resource_url.rb