moonrope 1.1.0 → 1.1.1

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: c2c07e3a6cf5bed85f04b415aba7c0a93eaac01c
4
- data.tar.gz: 54224342f109ced1f812419c23453d63538b3af3
3
+ metadata.gz: ef945cc15907ff80fe15bc8d5e8cd01c439183e7
4
+ data.tar.gz: 29682cb87255200fb7c52dbec08c0e7b18ce6292
5
5
  SHA512:
6
- metadata.gz: 6d10f3add6366036c7ed1355d9b03ad53629019a16bbb3689b0e70b0cc01e9740bcee698dcd0fc26a386609676bbff9e7852a4a4da5a81c89d26a0099e56bd96
7
- data.tar.gz: 38d91c152c7208dcda97cf6e3ddb5ee95a5146c3790c4739b43da8513e45cfddd1951620379d7597a6eb1898716a0bcb74167f358043f3e463de4c7dbe4696a1
6
+ metadata.gz: 16c45bb324804dc8180a2e71940a952d50cb1c68464df6d619d1bef1b3beb63aa1557647f70a4c5b0294f0f7ba733ac7cf1ec9648e6e37ee1fabe517967c5a57
7
+ data.tar.gz: c7b40e7fe75f15ca75894c2df47a3db6d6a6dcc3c672c0d084e9a95711a5ea09c7ee9165d14e5946cad1093a7514448ce1920b536f5d15cd17cc0f507819f0f1
@@ -21,6 +21,7 @@ module Moonrope
21
21
  structure = Moonrope::Structure.new(@base, name)
22
22
  structure.dsl.instance_eval(&block) if block_given?
23
23
  @base.structures << structure
24
+ structure
24
25
  end
25
26
 
26
27
  #
@@ -39,6 +40,7 @@ module Moonrope
39
40
  end
40
41
  controller.dsl.instance_eval(&block) if block_given?
41
42
  @base.controllers << controller
43
+ controller
42
44
  end
43
45
 
44
46
  #
@@ -66,7 +68,9 @@ module Moonrope
66
68
  # @yield stores the block to execute for the helper
67
69
  #
68
70
  def helper(name, &block)
69
- @base.helpers << Moonrope::Helper.new(name, nil, &block)
71
+ helper_instance = Moonrope::Helper.new(name, nil, &block)
72
+ @base.helpers << helper_instance
73
+ helper_instance
70
74
  end
71
75
 
72
76
  end
@@ -115,27 +115,45 @@ module Moonrope
115
115
  # object and return a hash or nil if the structure doesn't
116
116
  # exist.
117
117
  #
118
- # @param structure [Moonrope::Structure or Symbol] the structure to be used
118
+ # @param structure_name [Moonrope::Structure or Symbol] the structure to be used
119
119
  # @param object [Object] the object to pass through the structure
120
120
  # @param options [Hash] options to pass to the strucutre hash generator
121
121
  #
122
- def structure(structure, object, options = {})
122
+ def structure(structure_name, object, options = {})
123
123
  if object
124
- structure = case structure
125
- when Symbol, String then @base.structure(structure.to_sym)
126
- when Moonrope::Structure then structure
127
- else
128
- raise Moonrope::Errors::Error, "Invalid structure '#{structure}'"
129
- end
130
- if structure
124
+ structure = structure_for(structure_name)
125
+ if structure.is_a?(Moonrope::Structure)
131
126
  structure.hash(object, options.merge(:request => @request))
132
127
  else
133
- raise Moonrope::Errors::Error, "No structure found named '#{structure}'"
128
+ raise Moonrope::Errors::Error, "No structure found named '#{structure_name}'"
134
129
  end
135
130
  else
136
131
  nil
137
132
  end
138
133
  end
139
134
 
135
+ #
136
+ # Return a Moonrope::Structure object for the provided name
137
+ #
138
+ # @param structure_name [Symbol or String] the structure to return
139
+ #
140
+ def structure_for(structure_name)
141
+ structure = case structure_name
142
+ when Symbol, String then @base.structure(structure_name.to_sym)
143
+ when Moonrope::Structure then structure_name
144
+ else
145
+ false
146
+ end
147
+ end
148
+
149
+ #
150
+ # Return whether or not a given structure name is valid?
151
+ #
152
+ # @param structure_name [Symbol or String] the structure to return
153
+ #
154
+ def has_structure_for?(structure_name)
155
+ self.structure_for(structure_name).is_a?(Moonrope::Structure)
156
+ end
157
+
140
158
  end
141
159
  end
@@ -1,3 +1,3 @@
1
1
  module Moonrope
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
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.0
4
+ version: 1.1.1
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-26 00:00:00.000000000 Z
11
+ date: 2014-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json