rlet 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d8831d96794b32700eb7377a96e984db93826ca
4
- data.tar.gz: 38aafb34b173433c9d7878623c7d4b8a4fe05a6e
3
+ metadata.gz: 0d88f8fb70037560e1a016207871a9e89024bd93
4
+ data.tar.gz: d7b35547adbd29ad6cb670f50b1e420501813992
5
5
  SHA512:
6
- metadata.gz: 092ffe94952422d38a1c2a61c6e97cd0a0a5e8f521545b19abe8699311b038d7df49947c19d5a36fbe93c21a12fa7ad34f9bd4287e4b0129f2ad42f71991b0d2
7
- data.tar.gz: 27cc34e82f63d86c55a89ea976ba98121427c09c5f54f6475229a3d5f06aa3e4f66d1a589d8c256fe191f4167d0afcd9c00dd36f86cc15235aae3472cd560a05
6
+ metadata.gz: 03d715937769b7356083fe1dfccada13155701dce32eb68a759f060e4669eeb0a23b27dd7d3b0ced3e1b6ead5ef8b6d3ce00832e755a23807e29204e0867dbbd
7
+ data.tar.gz: f0911a88f8299d5ee62e02735408c624cd6a3d27990b05473a90f3525f40f0398602915d9618c4ead587ad85cc1539daf50cbcdddf3d4037299d7e4e237008ef
data/README.md CHANGED
@@ -28,8 +28,6 @@ Or from bundler
28
28
 
29
29
  The gems contain two modules, Let and Concern. You can use them like so:
30
30
 
31
- require 'rlet'
32
-
33
31
  class ContactsController
34
32
  include Let
35
33
  include RestfulResource
@@ -50,6 +48,32 @@ The gems contain two modules, Let and Concern. You can use them like so:
50
48
  end
51
49
  end
52
50
 
51
+ Normally, you want to expose the methods as public methods. Sometimes,
52
+ you want to use protected methods. You can do so with `letp`:
53
+
54
+ class ContactsController
55
+ include Let
56
+ include RestfulResource
57
+
58
+ letp(:model) { Contact }
59
+
60
+ def show
61
+ respond_with resource
62
+ end
63
+ end
64
+
65
+ module RestfulResource
66
+ extend Concern
67
+
68
+ included do
69
+ letp(:resource) { model.find(id) }
70
+ letp(:id) { params[:id] }
71
+ end
72
+ end
73
+
74
+ This is useful for Rails installation that still have dynamically inferred
75
+ routes.
76
+
53
77
  Concern is embedded from ActiveSupport. If ActiveSupport::Concern is loaded, it will use that. This
54
78
  allows one to use concerns without having ActiveSupport as a dependency.
55
79
 
@@ -81,6 +105,8 @@ Additionally, to expose `let()` with instance variables for use in templates, yo
81
105
  end
82
106
  end
83
107
 
108
+ ***DEPRECATION NOTICE*** Expose is not needed in Rails. Use `helper_method` instead
109
+
84
110
  ### LazyOptions
85
111
 
86
112
  One pattern that comes up is creating a class which takes an option as an initializer, and then
@@ -171,11 +197,10 @@ We can refactor into:
171
197
 
172
198
  This pattern occurs so frequently that `rlet` not includes a `LazyOptions` concern.
173
199
 
174
- require 'rlet/lazy_options'
175
200
  module Intentions
176
201
  class Promise
177
202
  include Let
178
- include LazyOptions
203
+ include RLet::LazyOptions
179
204
  extend Intentions::Concerns::Register
180
205
 
181
206
  let(:promiser) { options[:promiser] }
@@ -1 +1,7 @@
1
+ require 'rlet/version'
1
2
  require 'rlet/let'
3
+
4
+ module RLet
5
+ autoload :LazyOptions, 'rlet/lazy_options'
6
+ autoload :Functional, 'rlet/functional'
7
+ end
@@ -1,3 +1,4 @@
1
+ # DEPRECATED: Use helper_method instead
1
2
  # Include this module if you want to expose methods as instance
2
3
  # variables for Rails templates
3
4
  #
@@ -6,9 +6,16 @@ module Let
6
6
  module ClassMethods
7
7
  def let(name, &block)
8
8
  define_method(name) do
9
- __memoized[name] ||= instance_eval(&block)
9
+ __memoized.fetch(name) do
10
+ __memoized[name] = instance_eval(&block)
11
+ end
10
12
  end
11
13
  end
14
+
15
+ def letp(name, &block)
16
+ let(name, &block)
17
+ protected(name)
18
+ end
12
19
  end
13
20
 
14
21
  # Implementation based on Rspec let()
@@ -0,0 +1,3 @@
1
+ module RLet
2
+ VERSION = "0.8.0"
3
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rlet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ho-Sheng Hsiao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-11 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2016-03-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: Use rspec's let() outside of rspec with concerns and functional operators
14
28
  email:
15
29
  - talktohosh@gmail.com
@@ -25,6 +39,7 @@ files:
25
39
  - lib/rlet/functional.rb
26
40
  - lib/rlet/lazy_options.rb
27
41
  - lib/rlet/let.rb
42
+ - lib/rlet/version.rb
28
43
  homepage: http://github.com/hosh/rlet
29
44
  licenses: []
30
45
  metadata: {}
@@ -44,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
59
  version: 1.3.6
45
60
  requirements: []
46
61
  rubyforge_project: rlet
47
- rubygems_version: 2.2.2
62
+ rubygems_version: 2.4.5.1
48
63
  signing_key:
49
64
  specification_version: 4
50
65
  summary: Lazy-eval and functional helpers