moonrope 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/moonrope.rb +1 -1
- data/lib/moonrope/action.rb +1 -1
- data/lib/moonrope/controller.rb +2 -1
- data/lib/moonrope/dsl/base_dsl.rb +2 -2
- data/lib/moonrope/dsl/controller_dsl.rb +8 -0
- data/lib/moonrope/dsl/structure_dsl.rb +1 -0
- data/lib/moonrope/structure.rb +8 -8
- data/lib/moonrope/structure_attribute.rb +1 -0
- data/lib/moonrope/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ca039ed24cf2290a693a3114f6c814394126950
|
4
|
+
data.tar.gz: c3b20c6c65d8fedc44bb81e2416ee8a80ab7dd49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9498a71459b3944f2054b5636ba09f7f7c3c0436697dbccb822849c8af7b3e65c977594bd2731d2b151c5596cfa189de440b993888379033e6383b303bf6828
|
7
|
+
data.tar.gz: 6371c78a68ff96cd6f376e20d05832fb97f6659e28e47b48258fe1e92fe27e46808a7165e3785c63716427d1d1f4cb7ba34353eb1347cd67de3fa22ffc63bfbd
|
data/lib/moonrope.rb
CHANGED
data/lib/moonrope/action.rb
CHANGED
@@ -147,7 +147,7 @@ module Moonrope
|
|
147
147
|
eval_environment = EvalEnvironment.new(@controller.base, request)
|
148
148
|
end
|
149
149
|
|
150
|
-
access_condition = self.access || @controller.base.default_access
|
150
|
+
access_condition = self.access || @controller.access || @controller.base.default_access
|
151
151
|
|
152
152
|
if eval_environment.auth
|
153
153
|
# If there's no authentication object, access is permitted otherwise
|
data/lib/moonrope/controller.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Moonrope
|
2
2
|
class Controller
|
3
3
|
|
4
|
-
attr_accessor :name, :actions, :befores
|
4
|
+
attr_accessor :name, :actions, :access, :befores
|
5
5
|
attr_reader :base, :dsl
|
6
6
|
|
7
7
|
#
|
@@ -15,6 +15,7 @@ module Moonrope
|
|
15
15
|
@base = base
|
16
16
|
@name = name
|
17
17
|
@actions = {}
|
18
|
+
@access = nil
|
18
19
|
@befores = []
|
19
20
|
@dsl = Moonrope::DSL::ControllerDSL.new(self)
|
20
21
|
@dsl.instance_eval(&block) if block_given?
|
@@ -43,6 +43,14 @@ module Moonrope
|
|
43
43
|
before_action
|
44
44
|
end
|
45
45
|
|
46
|
+
#
|
47
|
+
# Defines the access required for controller methods which do not
|
48
|
+
# define their own access.
|
49
|
+
#
|
50
|
+
def access(value = nil, &block)
|
51
|
+
@controller.access = block_given? ? block : value
|
52
|
+
end
|
53
|
+
|
46
54
|
#
|
47
55
|
# Defines a new helper for this controller.
|
48
56
|
#
|
@@ -51,6 +51,7 @@ module Moonrope
|
|
51
51
|
attribute.value_type = options[:type]
|
52
52
|
attribute.source_attribute = options[:source_attribute]
|
53
53
|
attribute.value = options[:value]
|
54
|
+
attribute.example = options[:eg] || options[:example]
|
54
55
|
attribute.groups = @groups
|
55
56
|
attribute.conditions = @conditions
|
56
57
|
@structure.attributes[type] << attribute
|
data/lib/moonrope/structure.rb
CHANGED
@@ -52,22 +52,22 @@ module Moonrope
|
|
52
52
|
hash = Hash.new
|
53
53
|
|
54
54
|
# Add the 'basic' structured fields
|
55
|
-
|
55
|
+
DeepMerge.deep_merge! hash_for_attributes(@attributes[:basic], object, environment), hash
|
56
56
|
|
57
57
|
# Always get a basic hash to work from
|
58
58
|
if self.basic.is_a?(Proc)
|
59
|
-
|
59
|
+
DeepMerge.deep_merge! environment.instance_eval(&self.basic), hash
|
60
60
|
end
|
61
61
|
|
62
62
|
# Enhance with the full hash if requested
|
63
63
|
if options[:full]
|
64
64
|
|
65
65
|
# Add the 'full' structured fields
|
66
|
-
|
66
|
+
DeepMerge.deep_merge! hash_for_attributes(@attributes[:full], object, environment), hash
|
67
67
|
|
68
68
|
if self.full.is_a?(Proc)
|
69
69
|
full_hash = environment.instance_eval(&self.full)
|
70
|
-
|
70
|
+
DeepMerge.deep_merge! full_hash,hash
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
@@ -76,14 +76,14 @@ module Moonrope
|
|
76
76
|
|
77
77
|
# Add structured expansions
|
78
78
|
@attributes[:expansion].each do |attribute|
|
79
|
-
next if options[:expansions].is_a?(Array) && !options[:expansions].include?(name.to_sym)
|
80
|
-
|
79
|
+
next if options[:expansions].is_a?(Array) && !options[:expansions].include?(attribute.name.to_sym)
|
80
|
+
DeepMerge.deep_merge! hash_for_attributes([attribute], object, environment), hash
|
81
81
|
end
|
82
82
|
|
83
83
|
# Add the expansions
|
84
84
|
expansions.each do |name, expansion|
|
85
85
|
next if options[:expansions].is_a?(Array) && !options[:expansions].include?(name.to_sym)
|
86
|
-
|
86
|
+
DeepMerge.deep_merge!({name.to_sym => environment.instance_eval(&expansion)}, hash)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -146,7 +146,7 @@ module Moonrope
|
|
146
146
|
#
|
147
147
|
def value_for_attribute(object, environment, attribute)
|
148
148
|
value = object.send(attribute.source_attribute)
|
149
|
-
if attribute.structure
|
149
|
+
if value && attribute.structure
|
150
150
|
# If a structure is required, lookup the desired structure and set the
|
151
151
|
# hash value as appropriate.
|
152
152
|
if structure = self.base.structure(attribute.structure)
|
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.2.
|
4
|
+
version: 1.2.2
|
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-07-
|
11
|
+
date: 2014-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|