Sha256: 89c82d918e162aaf027d000c9eb80160f42a08d5e6c3653bff590727b94563a1

Contents?: true

Size: 734 Bytes

Versions: 3

Compression:

Stored size: 734 Bytes

Contents

module MotionResource
  class Base
    class_attribute :collection_url, :member_url
    class_attribute :root_url, :default_url_options
    class_attribute :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

3 entries across 3 versions & 1 rubygems

Version Path
motion-resource-0.1.2 lib/motion-resource/urls.rb
motion-resource-0.1.1 lib/motion-resource/urls.rb
motion-resource-0.1.0 lib/motion-resource/urls.rb