Module: Effective::Resources::Klass
- Included in:
- Effective::Resource
- Defined in:
- app/models/effective/resources/klass.rb
Instance Method Summary collapse
- #active_model? ⇒ Boolean
- #active_record? ⇒ Boolean
- #controller_klass ⇒ Object
- #datatable_klass ⇒ Object
- #klass ⇒ Object
Instance Method Details
#active_model? ⇒ Boolean
36 37 38 |
# File 'app/models/effective/resources/klass.rb', line 36 def active_model? klass && klass.ancestors.include?(ActiveModel::Model) end |
#active_record? ⇒ Boolean
32 33 34 |
# File 'app/models/effective/resources/klass.rb', line 32 def active_record? klass && klass.ancestors.include?(ActiveRecord::Base) end |
#controller_klass ⇒ Object
24 25 26 27 28 29 30 |
# File 'app/models/effective/resources/klass.rb', line 24 def controller_klass "#{namespaced_class_name.pluralize}Controller".safe_constantize || "#{class_name.pluralize.classify}Controller".safe_constantize || "#{name.pluralize.classify}Controller".safe_constantize || "#{initialized_name.to_s.classify.pluralize}Controller".safe_constantize || "#{initialized_name.to_s.classify}Controller".safe_constantize end |
#datatable_klass ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/models/effective/resources/klass.rb', line 9 def datatable_klass if defined?(EffectiveDatatables) "#{namespaced_class_name.pluralize}Datatable".safe_constantize || "#{namespaced_module_name.pluralize}Datatable".safe_constantize || "#{namespaced_class_name.pluralize.gsub('::', '')}Datatable".safe_constantize || "#{class_name.pluralize.camelize}Datatable".safe_constantize || "#{class_name.pluralize.camelize.gsub('::', '')}Datatable".safe_constantize || "#{name.pluralize.camelize}Datatable".safe_constantize || "#{name.pluralize.camelize.gsub('::', '')}Datatable".safe_constantize || "Effective::Datatables::#{namespaced_class_name.pluralize}".safe_constantize || "Effective::Datatables::#{class_name.pluralize.camelize}".safe_constantize || "Effective::Datatables::#{name.pluralize.camelize}".safe_constantize end end |
#klass ⇒ Object
5 6 7 |
# File 'app/models/effective/resources/klass.rb', line 5 def klass @model_klass end |