lib/oxymoron.rb in oxymoron-1.0.2 vs lib/oxymoron.rb in oxymoron-1.0.3
- old
+ new
@@ -1,17 +1,20 @@
if defined?(::Rails)
+ require "oxymoron/oxymoron_form_builder"
+ require "oxymoron/config"
+ require "oxymoron/extensions/form_helper"
require "oxymoron/engine"
end
module Oxymoron
class Oxymoron
def initialize
Rails.application.reload_routes!
@routes, @states, @resources = {}, {}, {}
- @app_routes = Rails.application.routes.routes.select{|route| route.name.present? && route.constraints[:request_method]}
+ @app_routes = Rails.application.routes.routes.select{|route| route.name.present? && route.verb}
@app_routes_by_controller = @app_routes.select{|route| ['new', 'edit', 'show', 'index'].exclude?(route.defaults[:action])}.group_by{|route| route.defaults[:controller]}.delete_if {|k,v| k.nil?}
@app_routes.each do |route|
set_routes route
set_states route
@@ -27,11 +30,11 @@
return @routes
end
def set_states route
- if route.constraints[:request_method].match("GET")
+ if route.verb.match("GET")
path = route.path.spec.to_s.gsub('(.:format)', '')
url_matcher = "'#{path}'"
route.path.required_names.each do |required_name|
if requirement = route.requirements[required_name.to_sym]
@@ -82,10 +85,10 @@
if (current_route_path.start_with?(base_path))
for_hash[route.defaults[:action]] ||= {
url: route.path.spec.to_s.gsub('(.:format)', '.json'),
isArray: route.defaults[:is_array],
- method: /GET|POST|PUT|PATCH|DELETE/.match(route.constraints[:request_method].to_s).to_s
+ method: /GET|POST|PUT|PATCH|DELETE/.match(route.verb.to_s).to_s
}
end
end
end
\ No newline at end of file