Sha256: a28a3207691a0d3591e8fa65662ef0338e4e37be7c7511ac1d46e615ac14b1f0

Contents?: true

Size: 586 Bytes

Versions: 2

Compression:

Stored size: 586 Bytes

Contents

module Rapidash
  module Collection

    def self.included(base)
      base.extend ClassMethods
    end

    module ClassMethods
      def collection(name, attrs = {})
        path = attrs[:path] || name.to_s
        path.gsub!(/^\//, '')

        method = attrs[:method] || :get

        define_method("#{name}!") do
          original_url = @url

          @url += "/#{path}"
          @options[:method] = method
          result = call!

          @url = original_url

          result
        end
      end
    end
  end
end

class Rapidash::Base
  include Rapidash::Collection
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bcx-0.2.0 lib/rapidash/collection.rb
bcx-0.1.1 lib/rapidash/collection.rb