Sha256: ee192d1b34060dbe9d9ea48344b68b021397548a27ba0f8d0fd4e5d248f363b1

Contents?: true

Size: 747 Bytes

Versions: 16

Compression:

Stored size: 747 Bytes

Contents

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

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

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
domoscio_rails-0.2.16.9 lib/domoscio_rails/resource.rb
domoscio_rails-0.2.24 lib/domoscio_rails/resource.rb
domoscio_rails-0.2.23 lib/domoscio_rails/resource.rb
domoscio_rails-0.2.19 lib/domoscio_rails/resource.rb
domoscio_rails-0.2.14 lib/domoscio_rails/resource.rb
domoscio_rails-0.2.11 lib/domoscio_rails/resource.rb
domoscio_rails-0.2.10 lib/domoscio_rails/resource.rb
domoscio_rails-0.2.9 lib/domoscio_rails/resource.rb
domoscio_rails-0.2.8 lib/domoscio_rails/resource.rb
domoscio_rails-0.2.7 lib/domoscio_rails/resource.rb
domoscio_rails-0.2.6 lib/domoscio_rails/resource.rb
domoscio_rails-0.2.5 lib/domoscio_rails/resource.rb
domoscio_rails-0.2.4 lib/domoscio_rails/resource.rb
domoscio_rails-0.2.3 lib/domoscio_rails/resource.rb
domoscio_rails-0.2.2 lib/domoscio_rails/resource.rb
domoscio_rails-0.2.1 lib/domoscio_rails/resource.rb