towsta 0.3.9 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/towsta/version.rb +1 -1
- data/lib/towsta/vertical.rb +8 -3
- metadata +2 -2
data/lib/towsta/version.rb
CHANGED
data/lib/towsta/vertical.rb
CHANGED
@@ -74,6 +74,7 @@ module Towsta
|
|
74
74
|
export.delete :created_at
|
75
75
|
export.delete :updated_at
|
76
76
|
id_aux = export.delete(:id)
|
77
|
+
id_aux ? id_aux : '0'
|
77
78
|
export = {:creator => creator, :vertical => self.class.to_s, :attributes => export, :id => id_aux}
|
78
79
|
uri = URI.parse("http://manager.towsta.com/synchronizers/#{$towsta_secret}/import.json")
|
79
80
|
response = JSON.parse Net::HTTP.post_form(uri, {:code => export.to_json}).body.to_s, :symbolize_names => true
|
@@ -86,8 +87,8 @@ module Towsta
|
|
86
87
|
self.all[rand(position)]
|
87
88
|
end
|
88
89
|
|
89
|
-
def self.create args
|
90
|
-
self.new(args.merge(:id => nil)).save
|
90
|
+
def self.create args, creator=$towsta_default_author
|
91
|
+
self.new(args.merge(:id => nil)).save creator
|
91
92
|
end
|
92
93
|
|
93
94
|
def attributes
|
@@ -96,6 +97,10 @@ module Towsta
|
|
96
97
|
foreings = Vertical.all + [User]
|
97
98
|
if foreings.include? eval(attr.to_s).class
|
98
99
|
horizontal[attr] = eval(attr.to_s).id
|
100
|
+
elsif eval(attr.to_s).class == Time
|
101
|
+
horizontal[attr] = eval(attr.to_s).strftime('%m/%d/%Y %H:%M')
|
102
|
+
elsif eval(attr.to_s).class == DateTime
|
103
|
+
horizontal[attr] = eval(attr.to_s).strftime('%m/%d/%Y')
|
99
104
|
else
|
100
105
|
horizontal[attr] = eval(attr.to_s).to_s
|
101
106
|
end
|
@@ -164,7 +169,7 @@ module Towsta
|
|
164
169
|
|
165
170
|
def self.to_d value
|
166
171
|
if value.class == String
|
167
|
-
begin; DateTime.strptime(value, '%m/%d/%Y
|
172
|
+
begin; DateTime.strptime(value, '%m/%d/%Y');
|
168
173
|
rescue; nil; end
|
169
174
|
else
|
170
175
|
value
|