moonrope 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/moonrope/base.rb +2 -2
- data/lib/moonrope/dsl/base_dsl.rb +6 -2
- data/lib/moonrope/dsl/controller_dsl.rb +6 -2
- data/lib/moonrope/errors.rb +2 -0
- data/lib/moonrope/helper.rb +4 -1
- data/lib/moonrope/railtie.rb +12 -0
- data/lib/moonrope/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9692810430240c41d7a72ae72a4c9db1134359e
|
4
|
+
data.tar.gz: f87635e0c45475aab9be1f764af4661f736bd3a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d2a7fdb9279de606ea73fcb20dc6fe18bf6e2e13eb5016ee0bf6f513f3391fdc10d345eacab8b90474c249261e883af8312ea80c9004666fd092414f35f0586
|
7
|
+
data.tar.gz: 37b832788c055a6fc24361d9f7acae8957eed70fb392210500cfcd25f6232c97e7b259d6c2e3ea0f4776448bb5bb43ce57be4cb69a8af6bd8759cfbc86079031
|
data/lib/moonrope/base.rb
CHANGED
@@ -52,7 +52,7 @@ module Moonrope
|
|
52
52
|
def unload
|
53
53
|
@structures = []
|
54
54
|
@controllers = []
|
55
|
-
@helpers = []
|
55
|
+
@helpers = @helpers.is_a?(Array) ? @helpers.select { |h| h.options[:unloadable] == false } : []
|
56
56
|
@authenticator = nil
|
57
57
|
@default_access = nil
|
58
58
|
end
|
@@ -70,7 +70,7 @@ module Moonrope
|
|
70
70
|
self.loaded_from = directory
|
71
71
|
self
|
72
72
|
else
|
73
|
-
raise Moonrope::Error, "Can't reload Moonrope::Base as it wasn't required from a directory"
|
73
|
+
raise Moonrope::Errors::Error, "Can't reload Moonrope::Base as it wasn't required from a directory"
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -67,8 +67,12 @@ module Moonrope
|
|
67
67
|
# @param name [Symbol] the name of the helper
|
68
68
|
# @yield stores the block to execute for the helper
|
69
69
|
#
|
70
|
-
def helper(name, &block)
|
71
|
-
|
70
|
+
def helper(name, options = {}, &block)
|
71
|
+
if @base.helper(name, nil)
|
72
|
+
raise Moonrope::Errors::HelperAlreadyDefined, "Helper has already been defined with name `#{name}`"
|
73
|
+
end
|
74
|
+
|
75
|
+
helper_instance = Moonrope::Helper.new(name, nil, options, &block)
|
72
76
|
@base.helpers << helper_instance
|
73
77
|
helper_instance
|
74
78
|
end
|
@@ -49,8 +49,12 @@ module Moonrope
|
|
49
49
|
# @param name [Symbol] the name of the helper
|
50
50
|
# @yield stores the block to execute for the helper
|
51
51
|
#
|
52
|
-
def helper(name, &block)
|
53
|
-
@controller.base.
|
52
|
+
def helper(name, options = {}, &block)
|
53
|
+
if @controller.base.helper(name, @controller)
|
54
|
+
raise Moonrope::Errors::HelperAlreadyDefined, "Helper has already been defined with name `#{name}`"
|
55
|
+
end
|
56
|
+
|
57
|
+
@controller.base.helpers << Moonrope::Helper.new(name, @controller, options, &block)
|
54
58
|
end
|
55
59
|
end
|
56
60
|
end
|
data/lib/moonrope/errors.rb
CHANGED
data/lib/moonrope/helper.rb
CHANGED
@@ -10,6 +10,8 @@ module Moonrope
|
|
10
10
|
# @return [Proc] the proc to execute
|
11
11
|
attr_reader :block
|
12
12
|
|
13
|
+
# @return [Hash] options for this helper
|
14
|
+
attr_reader :options
|
13
15
|
|
14
16
|
#
|
15
17
|
# Initialize a new helper
|
@@ -18,9 +20,10 @@ module Moonrope
|
|
18
20
|
# @param controller [Moonrope::Controller] the controller the helper belongs to
|
19
21
|
# @yield stores the block for use later
|
20
22
|
#
|
21
|
-
def initialize(name, controller, &block)
|
23
|
+
def initialize(name, controller, options = {}, &block)
|
22
24
|
@name = name
|
23
25
|
@controller = controller
|
26
|
+
@options = options
|
24
27
|
@block = block
|
25
28
|
end
|
26
29
|
|
data/lib/moonrope/railtie.rb
CHANGED
@@ -27,8 +27,20 @@ module Moonrope
|
|
27
27
|
result.status = 'not-found'
|
28
28
|
result.data = {:message => exception.message}
|
29
29
|
end
|
30
|
+
|
31
|
+
# Add a helper for auto setting parameters
|
32
|
+
app.config.moonrope.dsl.instance_eval do
|
33
|
+
helper :auto_set_params_for, :unloadable => false do |object|
|
34
|
+
current_action = object.new_record? ? :create_only : :update_only
|
35
|
+
request.action.params.select { |k,v| v[:set] == true || v[:set] == current_action }.keys.each do |param|
|
36
|
+
object.send("#{param}=", params[param]) if params.has?(param)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
30
40
|
end
|
31
41
|
|
42
|
+
puts app.config.moonrope.helpers.inspect
|
43
|
+
|
32
44
|
# Insert the Moonrope middleware into the application's middleware
|
33
45
|
# stack (at the bottom).
|
34
46
|
app.middleware.use(
|
data/lib/moonrope/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moonrope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
144
|
version: '0'
|
145
145
|
requirements: []
|
146
146
|
rubyforge_project:
|
147
|
-
rubygems_version: 2.2.
|
147
|
+
rubygems_version: 2.2.2
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: An API server DSL.
|