Sha256: 11153cf3a5b091e324d5ac0213475842add0fec2625c44b65814b9f35310d2ec

Contents?: true

Size: 648 Bytes

Versions: 3

Compression:

Stored size: 648 Bytes

Contents

module DomoscioRails
  # @abstract
  class Resource
    class << self
      def class_name
        name.split('::')[-1]
      end

      def url(id = nil, util_name = nil)
        if self == Resource
          raise NotImplementedError.new('Resource is an abstract class. Do not use it directly.')
        end
        
        build_url = "/v1/companies/#{DomoscioRails.configuration.client_id}"
        build_url << "/#{class_name.underscore}s"
        if util_name
          build_url << "/#{util_name}"
        end
        if id
          build_url << "/#{CGI.escape(id.to_s)}"
        end
        return build_url  
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
domoscio_rails-0.0.7 lib/domoscio_rails/resource.rb
domoscio_rails-0.0.6 lib/domoscio_rails/resource.rb
domoscio_rails-0.0.5 lib/domoscio_rails/resource.rb