Class: Adminable::Resource
- Inherits:
-
Object
- Object
- Adminable::Resource
- Includes:
- Comparable
- Defined in:
- lib/adminable/resource.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(name) ⇒ Resource
constructor
A new instance of Resource.
-
#route ⇒ String
For route helper name.
Constructor Details
#initialize(name) ⇒ Resource
Returns a new instance of Resource.
8 9 10 11 |
# File 'lib/adminable/resource.rb', line 8 def initialize(name) @name = name @model = name.classify.constantize end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
5 6 7 |
# File 'lib/adminable/resource.rb', line 5 def fields @fields end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
5 6 7 |
# File 'lib/adminable/resource.rb', line 5 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/adminable/resource.rb', line 5 def name @name end |
Instance Method Details
#<=>(other) ⇒ Object
18 19 20 |
# File 'lib/adminable/resource.rb', line 18 def <=>(other) other.is_a?(Adminable::Resource) && name <=> other.name end |
#route ⇒ String
Returns for route helper name.
14 15 16 |
# File 'lib/adminable/resource.rb', line 14 def route @route ||= @model.name.underscore.pluralize.tr('/', '_') end |