contextio 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changes
2
2
 
3
+ ## 1.2.0
4
+
5
+ * Add `#empty?` and `#size` to resource collections so you can treat them even
6
+ *more* like arrays! - Geoff Longman
7
+
3
8
  ## 1.1.0
4
9
 
5
10
  * Allow passing options to `OAuth` through the gem. Notably, `:timeout` and
data/README.md CHANGED
@@ -19,7 +19,7 @@ boolean has converted to something with a `?` at the end (e.g. `HasChildren` and
19
19
  `initial_import_finished` are `has_children?` and `initial_import_finished?`,
20
20
  respectively).
21
21
 
22
- ## Example
22
+ ## Examples
23
23
 
24
24
  ```ruby
25
25
  require 'contextio'
@@ -37,6 +37,19 @@ account.messages.where(folder: '\Drafts').each do |m|
37
37
  end
38
38
  ```
39
39
 
40
+ To grab some object you already know the primary key for, you'll use the `[]`
41
+ method like you would for a `Hash` or `Array`. This is most helpful for
42
+ accounts, but works for any resource collection.
43
+
44
+ ```ruby
45
+ require 'contextio'
46
+
47
+ contextio = ContextIO.new('your_api_key', 'your_api_secret')
48
+
49
+ account = contextio.accounts[some_account_id]
50
+ email_Address = account.messages[some_message_id]
51
+ ```
52
+
40
53
  ## Install
41
54
 
42
55
  $ gem install contextio
@@ -53,6 +53,22 @@ class ContextIO
53
53
  end
54
54
  end
55
55
 
56
+ # Returns the number of elements in self. May be zero.
57
+ #
58
+ # @note Calling this method will load the collection if not already loaded.
59
+ def size
60
+ attribute_hashes.size
61
+ end
62
+ alias :length, :size
63
+ alias :count, :size
64
+
65
+ # Returns true if self contains no elements.
66
+ #
67
+ # @note Calling this method will load the collection if not already loaded.
68
+ def empty?
69
+ size == 0
70
+ end
71
+
56
72
  # Specify one or more constraints for limiting resources in this
57
73
  # collection. See individual classes for the list of valid constraints.
58
74
  # Not all collections have valid where constraints at all.
@@ -1,6 +1,6 @@
1
1
  class ContextIO
2
2
  # @private
3
- VERSION = "1.1.0"
3
+ VERSION = "1.2.0"
4
4
 
5
5
  # The gem version.
6
6
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contextio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-07 00:00:00.000000000 Z
12
+ date: 2013-01-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth