Class: Adminable::Resource
- Inherits:
-
Object
- Object
- Adminable::Resource
- Defined in:
- lib/adminable/resource.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Array
readonly
Collection, see Attributes::Collection.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#includes ⇒ Array
Of associations names for ActiveRecord queries.
-
#initialize(name) ⇒ Resource
constructor
A new instance of Resource.
-
#route ⇒ String
For route helper name.
Constructor Details
#initialize(name) ⇒ Resource
6 7 8 9 |
# File 'lib/adminable/resource.rb', line 6 def initialize(name) @name = name @model = name.classify.constantize end |
Instance Attribute Details
#attributes ⇒ Array (readonly)
26 27 28 |
# File 'lib/adminable/resource.rb', line 26 def attributes @attributes 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
#==(other) ⇒ Object
30 31 32 |
# File 'lib/adminable/resource.rb', line 30 def ==(other) other.is_a?(Adminable::Resource) && name == other.name end |
#includes ⇒ Array
17 18 19 20 21 22 23 |
# File 'lib/adminable/resource.rb', line 17 def includes @includes ||= if attributes.associations.present? attributes.associations.map(&:name) else false end end |
#route ⇒ String
12 13 14 |
# File 'lib/adminable/resource.rb', line 12 def route @route ||= @model.name.underscore.pluralize.tr('/', '_') end |