lib/pipekit/repository.rb in pipekit-1.0.0 vs lib/pipekit/repository.rb in pipekit-1.0.1
- old
+ new
@@ -3,12 +3,12 @@
def initialize(request = nil)
@request = request || Request.new(resource)
end
- def all
- get
+ def all(query = {})
+ request.get("", query)
end
# Public: Get all records from Pipedrive by **one** of the record's fields.
#
# options - A Hash with one key-value pair. Key is a field name and values is a field value.
@@ -44,12 +44,12 @@
# Public: Create a record on Pipedrive.
#
# fields - fields for the record.
#
- # Examples
#
+ # Examples
# create({name: "John Doe", deal_id: 123})
#
# Returns nothing.
def create(fields)
request.post(fields)
@@ -66,20 +66,10 @@
# Returns nothing.
def update(id, fields)
request.put(id, fields)
end
- def self.included(base)
- base.extend(ClassMethods)
- end
-
- module ClassMethods
- def resource
- to_s.split("::").last.tap { |name| name[0] = name[0].downcase }
- end
- end
-
private
attr_reader :request
def method_missing(method_name, *args)
@@ -101,9 +91,9 @@
result = request.search_by_field(field: field, value: value)
result.map { |item| get_by_id(item["id"]) }.flatten
end
def resource
- self.class.resource
+ self.class.to_s.split("::").last.tap { |name| name[0] = name[0].downcase }
end
end
end