Sha256: 0e0d7b3374bc67681af1bae28e177f1e6c11a00659ad7e389df61e57e8ce2151

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

module ConferenceManager
  class Resource < ActiveResource::Base
    class << self
      def domain
        "http://vcc-test.dit.upm.es:8080"
      end
      
      def subclasses
        @subclasses ||= []
      end
      
      def inherited(subclass)
        @subclasses = subclasses | Array(subclass)
        super
      end
      
      def reload
        subclasses.each{ |subclass|
          subclass.site = subclass.domain
        }
      end

      # This is a single resource, like web or recording, but not events.
      def singleton
        @singleton = true
      end

      # redefine this two methods to remove .format extension
      def collection_path(prefix_options = {}, query_options = nil)
        prefix_options, query_options = split_options(prefix_options) if query_options.nil?
        @singleton ?
        "#{prefix(prefix_options)}#{collection_name.singularize}#{query_string(query_options)}" :
        "#{prefix(prefix_options)}#{collection_name}#{query_string(query_options)}"
      end
      
      
      def element_path(id, prefix_options = {}, query_options = nil)
        prefix_options, query_options = split_options(prefix_options) if query_options.nil?
        @singleton ?
        "#{prefix(prefix_options)}#{collection_name.singularize}#{query_string(query_options)}" :
        "#{prefix(prefix_options)}#{collection_name}/#{id}#{query_string(query_options)}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
conference_manager-ruby-0.0.3 lib/conference_manager/resource.rb