Skip to content

Commit a68161e

Browse files
seandmccarthycbeer
authored andcommitted
Ensure time options are strings before parsing. Pass map_{prefix} and to_{prefix} respond_to? questions down to the wrapped model.
1 parent b53986a commit a68161e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

lib/oai/provider/model/activerecord_wrapper.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def initialize(model, options={})
2424
)
2525
end
2626
end
27-
27+
2828
def earliest
2929
model.find(:first,
3030
:order => "#{timestamp_field} asc").send(timestamp_field)
@@ -65,6 +65,22 @@ def deleted?(record)
6565
false
6666
end
6767

68+
def respond_to?(m, *args)
69+
if m =~ /^map_/
70+
model.respond_to?(m, *args)
71+
else
72+
super
73+
end
74+
end
75+
76+
def method_missing(m, *args, &block)
77+
if m =~ /^map_/
78+
model.send(m, *args, &block)
79+
else
80+
super
81+
end
82+
end
83+
6884
protected
6985

7086
# Request the next set in this sequence.
@@ -120,7 +136,7 @@ def sql_conditions(opts)
120136
sql << "#{timestamp_field} >= ?" << "#{timestamp_field} <= ?"
121137
sql << "set = ?" if opts[:set]
122138
esc_values = [sql.join(" AND ")]
123-
esc_values << Time.parse(opts[:from]).localtime << Time.parse(opts[:until]).localtime #-- OAI 2.0 hack - UTC fix from record_responce
139+
esc_values << Time.parse(opts[:from].to_s).localtime << Time.parse(opts[:until].to_s).localtime.to_s #-- OAI 2.0 hack - UTC fix from record_responce
124140
esc_values << opts[:set] if opts[:set]
125141

126142
return esc_values

0 commit comments

Comments
 (0)