Sha256: 1f39a7a9b531d1fe6f162e3606f6779faf6f534292a64ef18185909f6e63fec2

Contents?: true

Size: 662 Bytes

Versions: 7

Compression:

Stored size: 662 Bytes

Contents

require 'acfs/service/request_handler'
require 'acfs/service/middleware'

module Acfs

  # Service object.
  #
  class Service
    attr_accessor :options
    class_attribute :base_url

    include Service::RequestHandler
    include Service::Middleware

    def initialize(options = {})
      @options = options
    end

    def options
      @options
    end

    def url_for(resource_class, options = {})
      options.reverse_merge! self.options

      url  = self.class.base_url.to_s
      url += "/#{(options[:path] || resource_class.name.pluralize.underscore).to_s}"
      url += "/#{options[:suffix].to_s}" if options[:suffix]
      url
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
acfs-0.14.0 lib/acfs/service.rb
acfs-0.13.0 lib/acfs/service.rb
acfs-0.12.0 lib/acfs/service.rb
acfs-0.11.0 lib/acfs/service.rb
acfs-0.10.0 lib/acfs/service.rb
acfs-0.9.0 lib/acfs/service.rb
acfs-0.8.0 lib/acfs/service.rb