Sha256: 46c257a93ee21c0e908ae48aef3b70d9e74f8acad9743986b1852d8389763e4b
Contents?: true
Size: 1005 Bytes
Versions: 1
Compression:
Stored size: 1005 Bytes
Contents
require 'acfs/service/middleware' module Acfs # Service object. # class Service attr_accessor :options 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 class << self def identity(identity = nil) @identity = identity.to_s.to_sym unless identity.nil? @identity ||= name.to_sym end def base_url unless (base = Acfs::Configuration.current.locate identity) raise ArgumentError, "#{identity} not configured. Add `locate '#{identity.to_s.underscore}', 'http://service.url/'` to your configuration." end base.to_s end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acfs-0.16.0 | lib/acfs/service.rb |