README.md in cistern-0.12.3 vs README.md in cistern-1.0.0.pre
- old
+ new
@@ -56,33 +56,10 @@
```ruby
Foo::Client.requests # => [:get_bar, :get_bars]
```
-##### Forward Compatible
-
-Ish.
-
-```ruby
-# client/requests/get_bar.rb
-class Foo:Client::GetBar
-
- service Foo::Client
-
- def real(bar_id)
- connection.request("http://example.org/bar/#{bar_id}")
- end
-
- def mock
- # do some mock things
- end
-end
-```
-
-In this context, `connection` is reference to the `Cistern::Service`.
-
-
#### Models and Collections
Models and collections have declaration semantics similar to requests. Models and collections are enumerated via `model` and `collection` respectively.
```ruby
@@ -229,11 +206,11 @@
Patient::Mock.store_in(:hash)
```
### Model
-* `connection` represents the associated `Foo::Client` instance.
+* `service` represents the associated `Foo::Client` instance.
* `collection` represents the related collection (if applicable)
Example
```ruby
@@ -246,11 +223,11 @@
def destroy
params = {
"id" => self.identity
}
- self.connection.destroy_bar(params).body["request"]
+ self.service.destroy_bar(params).body["request"]
end
def save
requires :keypair_id
@@ -260,15 +237,15 @@
"flavor" => self.flavor,
},
}
if new_record?
- merge_attributes(connection.create_bar(params).body["bar"])
+ merge_attributes(service.create_bar(params).body["bar"])
else
requires :identity
- merge_attributes(connection.update_bar(params).body["bar"])
+ merge_attributes(service.update_bar(params).body["bar"])
end
end
end
```
@@ -307,11 +284,11 @@
class Foo::Client::Bars < Cistern::Collection
model Foo::Client::Bar
def all(params = {})
- response = connection.get_bars(params)
+ response = service.get_bars(params)
data = response.body
self.load(data["bars"]) # store bar records in collection
self.merge_attributes(data) # store any other attributes of the response on the collection
@@ -321,14 +298,14 @@
params = {
"provisioned_id" => provisioned_id,
}
params.merge!("location" => options[:location]) if options.key?(:location)
- connection.requests.new(connection.discover_bar(params).body["request"])
+ service.requests.new(service.discover_bar(params).body["request"])
end
def get(id)
- if data = connection.get_bar("id" => id).body["bar"]
+ if data = service.get_bar("id" => id).body["bar"]
new(data)
else
nil
end
end