roda-action 0.0.3 → 0.1.0

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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -9
  3. data/lib/roda/plugins/action.rb +6 -0
  4. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 58972c954d302e8d2fea2797a79c133c0a21f9d1
4
- data.tar.gz: 572b424d95e0f6a3b2dfd6fd7a633f951af6be9f
3
+ metadata.gz: fe13a1e82411d9fa8e993940512347f734bf7166
4
+ data.tar.gz: 8e5e19bbef13019484f3b1bb3bfb42720d838577
5
5
  SHA512:
6
- metadata.gz: 361eef4f9df7622fc00daac3f9e0c7ba4b62087aa64a3ac7720985d1e71ef68d79f05ed6283593879d3746cb57b82d755954248eedc19f062a8da1aaa174c123
7
- data.tar.gz: c57c48b1cf5e4e0b4bb5685ee31ba16a364f124d2a1953ccb6025cc4a36bbb83807bfa56a66fc24c9d83d758ed2a9bcbd1476afab550e3a5e6ba372ff1b6c151
6
+ metadata.gz: 22270429c09091d13a10407ff74545bb999c4fa8d802c4de1826997442d5bb50dc70fe7fa08a081f0351fd1734c1092ba648ec195dc08451fec5754739144b75
7
+ data.tar.gz: 404d94426405fbbf1178449e19e1ec97f48d5b7c0033d81dd2225e094afaf65cd46a2e91a29abb2fc33a8d086a63e9af3a3f3b98e8246319542e20d4d00a5a93
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # roda-action
1
+ # roda-action <a href="https://gitter.im/AMHOL/roda-action" target="_blank">![Join the chat at https://gitter.im/AMHOL/roda-action](https://badges.gitter.im/Join%20Chat.svg)</a>
2
2
 
3
3
  A plugin for Roda to resolve actions from roda-container
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```ruby
8
- gem 'roda-action', '0.0.2'
8
+ gem 'roda-action', '0.1.0'
9
9
  ```
10
10
 
11
11
  ## Usage
@@ -42,11 +42,11 @@ end
42
42
  MyApplication.route do |r|
43
43
  r.on 'users' do
44
44
  r.is do
45
- r.get(&MyApplication.action(:users_controller, :index))
45
+ r.get(&action(:users_controller, :index))
46
46
  end
47
47
 
48
48
  r.is :id do |id|
49
- r.get(&MyApplication.action(:users_controller, :show).bind_arguments(id))
49
+ r.get(&action(:users_controller, :show).bind_arguments(id))
50
50
  end
51
51
  end
52
52
  end
@@ -54,6 +54,8 @@ end
54
54
 
55
55
  If you wish to have access to the usual Roda application instance methods in your registered controllers, it is recommended that you register the application and resolve it for use in your controllers:
56
56
 
57
+ NOTE: Be sure to use `.instance` as below, see: https://github.com/AMHOL/roda-container#thread-safety
58
+
57
59
  ```ruby
58
60
  class MyApplication < Roda
59
61
  plugin :json
@@ -91,20 +93,23 @@ MyApplication.register(:users_repository, [
91
93
  ])
92
94
 
93
95
  MyApplication.register(:users_controller) do
94
- UsersController.new(MyApplication.instance.resolve(:app), MyApplication.resolve(:users_repository))
96
+ UsersController.new(
97
+ MyApplication.instance.resolve(:app),
98
+ MyApplication.resolve(:users_repository)
99
+ )
95
100
  end
96
101
 
97
102
  MyApplication.route do |r|
98
- MyApplication.instance.register(:app, self, call: false)
103
+ register(:app, self, call: false)
99
104
 
100
105
  r.on 'users' do
101
106
  r.is do
102
- r.get(&MyApplication.action(:users_controller, :index))
103
- r.post(&MyApplication.action(:users_controller, :create))
107
+ r.get(&action(:users_controller, :index))
108
+ r.post(&action(:users_controller, :create))
104
109
  end
105
110
 
106
111
  r.is :id do |id|
107
- r.get(&MyApplication.action(:users_controller, :show).bind_arguments(id))
112
+ r.get(&action(:users_controller, :show).bind_arguments(id))
108
113
  end
109
114
  end
110
115
  end
@@ -75,6 +75,12 @@ class Roda
75
75
  Action.new(resolve(controller_key).method(action))
76
76
  end
77
77
  end
78
+
79
+ module InstanceMethods
80
+ def action(*args, &block)
81
+ self.class.action(*args, &block)
82
+ end
83
+ end
78
84
  end
79
85
 
80
86
  register_plugin(:action, Action)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda-action
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Holland
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-19 00:00:00.000000000 Z
11
+ date: 2015-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: roda-container
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.4
19
+ version: 0.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.0.4
26
+ version: 0.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement