Sha256: eb08338b6b113e997974e44194f7198f0273c5052028f1b48f763539603491b0

Contents?: true

Size: 744 Bytes

Versions: 2

Compression:

Stored size: 744 Bytes

Contents

module ChatWork
  module Operations
    def install_class_operations(*operations)
      define_create if operations.include?(:create)
      define_get if operations.include?(:get)
    end

    def define_get
      instance_eval do
        def get(params = {})
          convert(ChatWork.client.get(path, params))
        end
      end
    end

    def define_create
      instance_eval do
        def create(params = {})
          # TODO: Consider other pattern
          # /rooms and /rooms/:room_id
          assign_path = if params.include?(:room_id)
            path % params.delete(:room_id)
          else
            path
          end
          convert(ChatWork.client.post(assign_path, params))
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chatwork-0.0.6 lib/chatwork/operations.rb
chatwork-0.0.5 lib/chatwork/operations.rb