Sha256: 83f129729bfec6201b02fe9cbd17acb51d6fc69aa81f4c0bd0fb48b8eef30194

Contents?: true

Size: 767 Bytes

Versions: 2

Compression:

Stored size: 767 Bytes

Contents

module MotionResource
  class Base
    class_inheritable_accessor :collection_url, :member_url
    class_inheritable_accessor :root_url, :default_url_options
    class_inheritable_accessor :extension
    self.extension = '.json'
    
    class << self
      def custom_urls(params = {})
        params.each do |name, url_format|
          define_method name do |params = {}|
            url_format.fill_url_params(params, self)
          end
          define_singleton_method name do
            url_format
          end
        end
      end
    end

    def collection_url(params = {})
      self.class.collection_url.fill_url_params(params, self)
    end

    def member_url(params = {})
      self.class.member_url.fill_url_params(params, self)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
motion-resource-0.0.2 lib/motion-resource/urls.rb
motion-resource-0.0.1 lib/motion-resource/urls.rb