Class: Adminable::Resource
- Inherits:
-
Object
- Object
- Adminable::Resource
- Defined in:
- lib/adminable/resource.rb
Instance Attribute Summary collapse
- #attributes ⇒ Object
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #includes ⇒ Object
-
#initialize(name) ⇒ Resource
constructor
A new instance of Resource.
- #route ⇒ Object
Constructor Details
#initialize(name) ⇒ Resource
Returns a new instance of Resource.
6 7 8 9 10 11 |
# File 'lib/adminable/resource.rb', line 6 def initialize(name) @name = name @model = name.classify.constantize load_extensions end |
Instance Attribute Details
#attributes ⇒ Object
25 26 27 |
# File 'lib/adminable/resource.rb', line 25 def attributes @attributes ||= Adminable::Attributes::Collection.new(@model) end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
3 4 5 |
# File 'lib/adminable/resource.rb', line 3 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/adminable/resource.rb', line 3 def name @name end |
Instance Method Details
#includes ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/adminable/resource.rb', line 17 def includes @includes ||= if attributes.association.present? attributes.association.map { |k, v| v.name } else false end end |
#route ⇒ Object
13 14 15 |
# File 'lib/adminable/resource.rb', line 13 def route @route ||= @model.name.underscore.pluralize.tr('/', '_') end |