Module: Madmin
- Defined in:
- lib/madmin/search.rb,
lib/madmin.rb,
lib/madmin/menu.rb,
lib/madmin/field.rb,
lib/madmin/engine.rb,
lib/madmin/version.rb,
lib/madmin/resource.rb,
lib/madmin/namespace.rb,
lib/madmin/fields/date.rb,
lib/madmin/fields/enum.rb,
lib/madmin/fields/file.rb,
lib/madmin/fields/json.rb,
lib/madmin/fields/text.rb,
lib/madmin/fields/time.rb,
lib/madmin/fields/float.rb,
lib/madmin/fields/select.rb,
lib/madmin/fields/string.rb,
lib/madmin/fields/boolean.rb,
lib/madmin/fields/decimal.rb,
lib/madmin/fields/has_one.rb,
lib/madmin/fields/integer.rb,
lib/madmin/view_generator.rb,
lib/madmin/fields/currency.rb,
lib/madmin/fields/has_many.rb,
lib/madmin/fields/password.rb,
lib/madmin/fields/date_time.rb,
lib/madmin/fields/rich_text.rb,
lib/madmin/resource_builder.rb,
lib/madmin/fields/attachment.rb,
lib/madmin/fields/belongs_to.rb,
lib/madmin/generator_helpers.rb,
lib/madmin/fields/attachments.rb,
lib/madmin/fields/polymorphic.rb,
app/helpers/madmin/sort_helper.rb,
lib/madmin/fields/nested_has_many.rb,
app/helpers/madmin/application_helper.rb,
app/controllers/madmin/base_controller.rb,
lib/generators/madmin/views/new_generator.rb,
app/controllers/madmin/resource_controller.rb,
lib/generators/madmin/views/edit_generator.rb,
lib/generators/madmin/views/form_generator.rb,
lib/generators/madmin/views/show_generator.rb,
app/controllers/madmin/dashboard_controller.rb,
lib/generators/madmin/field/field_generator.rb,
lib/generators/madmin/views/index_generator.rb,
lib/generators/madmin/views/views_generator.rb,
lib/generators/madmin/views/layout_generator.rb,
app/controllers/madmin/application_controller.rb,
lib/generators/madmin/install/install_generator.rb,
lib/generators/madmin/views/javascript_generator.rb,
lib/generators/madmin/views/navigation_generator.rb,
lib/generators/madmin/resource/resource_generator.rb
Overview
Defined Under Namespace
Modules: ApplicationHelper, Fields, GeneratorHelpers, Generators, NavHelper, SortHelper
Classes: ApplicationController, BaseController, DashboardController, Engine, Field, Menu, Namespace, Resource, ResourceBuilder, ResourceController, Search, ViewGenerator
Constant Summary
collapse
- VERSION =
"2.0.0"
Class Method Summary
collapse
Class Method Details
.reset_resources! ⇒ Object
69
70
71
72
|
# File 'lib/madmin.rb', line 69
def reset_resources!
@resources = nil
.reset
end
|
.resource_by_name(name) ⇒ Object
61
62
63
|
# File 'lib/madmin.rb', line 61
def resource_by_name(name)
"#{name}Resource".constantize
end
|
.resource_for(object) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/madmin.rb', line 44
def resource_for(object)
if object.is_a? ::ActiveStorage::Attached
"ActiveStorage::AttachmentResource".constantize
else
begin
"#{object.class.name}Resource".constantize
rescue
if (column = object.class.inheritance_column) && object.class.column_names.include?(column)
"#{object.class.superclass.base_class.name}Resource".constantize
else
raise
end
end
end
end
|
.resource_names ⇒ Object
74
75
76
77
78
|
# File 'lib/madmin.rb', line 74
def resource_names
root = Rails.root.join("app/madmin/resources/")
files = Dir.glob(root.join("**/*.rb"))
files.sort!.map! { |f| f.split(root.to_s).last.delete_suffix(".rb").classify }
end
|
.resources ⇒ Object
65
66
67
|
# File 'lib/madmin.rb', line 65
def resources
@resources ||= resource_names.map(&:constantize)
end
|