omnis 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/omnis/transformer.rb +4 -0
- data/lib/omnis/version.rb +1 -1
- data/spec/lib/omnis/transformer_spec.rb +5 -0
- metadata +1 -1
data/lib/omnis/transformer.rb
CHANGED
@@ -65,6 +65,10 @@ module Omnis
|
|
65
65
|
end
|
66
66
|
|
67
67
|
module InstanceMethods
|
68
|
+
def columns
|
69
|
+
self.class.properties.keys
|
70
|
+
end
|
71
|
+
|
68
72
|
def property_value(property, source)
|
69
73
|
raw_value = property.extract(source)
|
70
74
|
raw_value = property.default if property.default && (raw_value == Nothing || raw_value.nil?)
|
data/lib/omnis/version.rb
CHANGED
@@ -37,6 +37,11 @@ describe Omnis::Transformer do
|
|
37
37
|
t.transform(doc).should == { :ref => "1abc" }
|
38
38
|
end
|
39
39
|
|
40
|
+
it "allows to get a list of columns (property names)" do
|
41
|
+
t = TestTransformer.new
|
42
|
+
t.columns.should == [:ref, :date_from, :date_to, :agency]
|
43
|
+
end
|
44
|
+
|
40
45
|
it "uses a #to_object method if provided to convert the resulting Hash into an Object" do
|
41
46
|
class TestTransformerWithToObject
|
42
47
|
include Omnis::Transformer
|