moonrope 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/moonrope/eval_environment.rb +23 -9
- data/lib/moonrope/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81c19996325ee4342d9c027d043e03dc15dbf4b1
|
4
|
+
data.tar.gz: 6a5859ecd39d546385894fd3d114aee48b0dd166
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8795f460fcbb66d4c93acd896fcb2a1e15b73650f3e824069366fdb3d8fd3a6699a3fce21f2b76c41387070d9cd52730f34b94984750880258783c6644e2ec1
|
7
|
+
data.tar.gz: 02fc479ae9b0c7609935605c7296eab781eaf3d8d82ced6e826f94b24fc965fca1ce5ba8f1a44926772ac79b36d4df21811b837501ab97caecc5f690b8abe4a8
|
@@ -119,17 +119,31 @@ module Moonrope
|
|
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(
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
122
|
+
def structure(structure_name_or_object, object_or_options = {}, options_if_structure_name = {})
|
123
|
+
|
124
|
+
if structure_name_or_object.is_a?(Symbol) || structure_name_or_object.is_a?(String) || structure_name_or_object.is_a?(Moonrope::Structure)
|
125
|
+
structure_name = structure_name_or_object
|
126
|
+
object = object_or_options
|
127
|
+
options = options_if_structure_name
|
128
|
+
elsif structure_name_or_object.class.name.respond_to?(:underscore)
|
129
|
+
structure_name = structure_name_or_object.class.name.underscore.to_sym
|
130
|
+
object = structure_name_or_object
|
131
|
+
options = object_or_options
|
130
132
|
else
|
131
|
-
|
133
|
+
raise Moonrope::Errors::Error, "Could not determine structure name"
|
132
134
|
end
|
135
|
+
|
136
|
+
if object.nil?
|
137
|
+
return nil
|
138
|
+
end
|
139
|
+
|
140
|
+
structure = structure_for(structure_name)
|
141
|
+
|
142
|
+
unless structure.is_a?(Moonrope::Structure)
|
143
|
+
raise Moonrope::Errors::Error, "No structure found named '#{structure_name}'"
|
144
|
+
end
|
145
|
+
|
146
|
+
structure.hash(object, options.merge(:request => @request))
|
133
147
|
end
|
134
148
|
|
135
149
|
#
|
data/lib/moonrope/version.rb
CHANGED