classproxy 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/README.md +30 -1
  2. data/lib/classproxy/version.rb +1 -1
  3. metadata +3 -3
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  class-proxy
2
2
  ===========
3
3
 
4
- A generic (yet ActiveRecord compliant) class proxy to setup proxy methods for your classes.
4
+ A generic (ActiveRecord compatible) class proxy to setup proxy methods for your classes.
5
5
 
6
6
  ## Using
7
7
 
@@ -10,6 +10,35 @@ provided by this gem.
10
10
 
11
11
  ### Example
12
12
 
13
+ #### Basic example
14
+
15
+ ```ruby
16
+ class UserDb
17
+ include MongoMapper::Document
18
+ include ClassProxy
19
+
20
+ primary_fetch { |args| where(args).first or (raise NotFound) }
21
+ fallback_fetch { |args| Octokit.user(args[:login]) }
22
+
23
+ key :name, String
24
+ key :login, String
25
+ end
26
+ ```
27
+
28
+ ```ruby
29
+ > user = UserDb.fetch(login: 'heelhook')
30
+ => #<UserDb _id: 779813, name: "Pablo Fernandez", login: "heelhook">
31
+ ```
32
+
33
+ In this example the database will be hit with a `where(login: 'heelhook')` and
34
+ if it comes back empty `Octokit` will be used to retrieve the information requested.
35
+
36
+ The default action (overwritten with `after_fallback_fetch`, not used in this example)
37
+ is to return a new object of the parent class (`UserDb`) with the proper keys set,
38
+ in this example `:id`, `:name` and `:login`.
39
+
40
+ #### Detailed example
41
+
13
42
  ```ruby
14
43
  class UserDb
15
44
  include MongoMapper::Document
@@ -1,3 +1,3 @@
1
1
  module ClassProxy
2
- VERSION = '0.7.0'
2
+ VERSION = '0.7.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: classproxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
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: 2012-12-14 00:00:00.000000000 Z
12
+ date: 2012-12-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -55,7 +55,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
55
55
  version: '0'
56
56
  segments:
57
57
  - 0
58
- hash: 1757276134507409389
58
+ hash: 1986855267871768364
59
59
  required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  none: false
61
61
  requirements: