diff --git a/lib/decent_exposure/behavior.rb b/lib/decent_exposure/behavior.rb index 9317ea2..04f5332 100644 --- a/lib/decent_exposure/behavior.rb +++ b/lib/decent_exposure/behavior.rb @@ -41,7 +41,7 @@ def scope(model) # # Returns a standard Class name. def model - name.to_s.classify.constantize + [model_namespace, name.to_s.classify].compact.join('::').constantize end # Public: Find an object on the supplied scope. @@ -84,6 +84,10 @@ def build_params end protected + def model_namespace + options[:model_namespace].to_s + end + def params_id_key_candidates ["#{model_param_key}_id", "#{name}_id", "id"].uniq diff --git a/lib/decent_exposure/exposure.rb b/lib/decent_exposure/exposure.rb index 5fc55fd..8a76945 100644 --- a/lib/decent_exposure/exposure.rb +++ b/lib/decent_exposure/exposure.rb @@ -82,6 +82,7 @@ def normalize_options normalize_parent_option normalize_from_option normalize_find_by_option + normalize_model_namespace_option end def normalize_fetch_option @@ -138,6 +139,12 @@ def normalize_model_option end end + def normalize_model_namespace_option + normalize_non_proc_option :model_namespace do |value| + -> { value.to_s } + end + end + def normalize_build_params_option normalize_non_proc_option :build_params do |value| options[:build_params_method] = value diff --git a/lib/decent_exposure/version.rb b/lib/decent_exposure/version.rb index e6a095d..f568db7 100644 --- a/lib/decent_exposure/version.rb +++ b/lib/decent_exposure/version.rb @@ -1,3 +1,3 @@ module DecentExposure - VERSION = "3.0.4" + VERSION = "3.0.5" end