Sha256: 1839f7a8e0958014b37154a80d0892b96e15b92825e517575cd45fc0038b760c
Contents?: true
Size: 740 Bytes
Versions: 2
Compression:
Stored size: 740 Bytes
Contents
# rubocop:disable Style/Documentation module Behaveable module ResourceFinder # Get the behaveable object. # # ==== Returns # * <tt>ActiveRecord::Model</tt> - Behaveable instance object. def behaveable klass, param = behaveable_class klass.find(params[param.to_sym]) if klass end private # Lookup behaveable class. # # ==== Returns # * <tt>Response</tt> - Behaveable class object or nil if not found. def behaveable_class params.each do |name, _value| if name =~ /(.+)_id$/ model = name.match(%r{([^\/.]*)_id$}) return model[1].classify.constantize, name end end nil end end end # rubocop:enable Style/Documentation
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
behaveable-0.1.2 | lib/behaveable/resource_finder.rb |
behaveable-0.1.1 | lib/behaveable/resource_finder.rb |