Module: ActiveRecordExtension::ClassMethods
- Defined in:
- lib/adminpanel/active_record_extension.rb
Overview
static(class) methods
Instance Method Summary collapse
- #belongs_to_relationships ⇒ Object
- #display_attributes ⇒ Object
- #display_name ⇒ Object
- #form_attributes ⇒ Object
- #has_images? ⇒ Boolean
- #has_many_relationships ⇒ Object
- #icon ⇒ Object
- #plural_name ⇒ Object
Instance Method Details
#belongs_to_relationships ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/adminpanel/active_record_extension.rb', line 48 def belongs_to_relationships belongs_to_classes = [] form_attributes.each do |fields| fields.each do |attribute, properties| if properties["type"] == "belongs_to" belongs_to_classes << properties["model"].classify.constantize end end end return belongs_to_classes end |
#display_attributes ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/adminpanel/active_record_extension.rb', line 20 def display_attributes display_attributes = [] form_attributes.each do |attribute| attribute.each do |name, properties| if properties["show"].nil? || properties["show"] == "true" display_attributes << attribute end end end return display_attributes end |
#display_name ⇒ Object
16 17 18 |
# File 'lib/adminpanel/active_record_extension.rb', line 16 def display_name "display_name" end |
#form_attributes ⇒ Object
10 11 12 13 14 |
# File 'lib/adminpanel/active_record_extension.rb', line 10 def form_attributes [{ "name" => {"type" => "text_field", "name" => ":name"} }] end |
#has_images? ⇒ Boolean
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/adminpanel/active_record_extension.rb', line 37 def has_images? form_attributes.each do |fields| fields.each do |attribute, properties| if properties["type"] == "adminpanel_file_field" return true end end end return false end |
#has_many_relationships ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/adminpanel/active_record_extension.rb', line 60 def has_many_relationships has_many_classes = [] form_attributes.each do |fields| fields.each do |attribute, properties| if properties["type"] == "has_many" has_many_classes << properties["model"].classify.constantize end end end return has_many_classes end |
#icon ⇒ Object
72 73 74 |
# File 'lib/adminpanel/active_record_extension.rb', line 72 def icon "icon-truck" end |
#plural_name ⇒ Object
33 34 35 |
# File 'lib/adminpanel/active_record_extension.rb', line 33 def plural_name display_name.pluralize end |