polymorphi
1 def build_named_route_ca ll(records, namespace, inflection , options = {}) 2 unless records.is_a?(Array) 3 record = extract_re cord(records) 4 route = '' 5 else 6 record = records.pop 7 route = records.inject("") do |string, parent| 8 if parent.is_a?(Symbol) || parent.is_a?(String) 9 string << "#{parent}_" 10 else 11 string << "#{RecordIden tifier.__send__("plural_cla ss_name", parent 12 )}".singulariz e 13 string << "_" 14 end 15 end 16 end 17 18 if record.is_a?(Symbol) || record.is_a?(String) 19 route << "#{record}_" 20 else 21 route << "#{RecordIden tifier.__send__("plural_cla ss_name", record)}" 22 route = route.singulariz e if inflection == :singular 23 route << "_" 24 end 25 26 action_pre fix(options) + namespace + route + routing_ty pe(options).to_s 27 end
posted by
genki
on Wed 1 Apr 2009
at 13:18