Class: Mattermost::ResourceName
- Inherits:
-
Object
- Object
- Mattermost::ResourceName
- Defined in:
- lib/mattermost/resource_name.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
-
#initialize(klass) ⇒ ResourceName
constructor
A new instance of ResourceName.
- #param_key ⇒ Object
- #path ⇒ Object
- #plural ⇒ Object
- #singular ⇒ Object
Constructor Details
#initialize(klass) ⇒ ResourceName
Returns a new instance of ResourceName.
5 6 7 8 9 10 11 |
# File 'lib/mattermost/resource_name.rb', line 5 def initialize(klass) @klass = if klass.name.index("::") klass.name.split("::").last else klass.name end end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
4 5 6 |
# File 'lib/mattermost/resource_name.rb', line 4 def klass @klass end |
Instance Method Details
#param_key ⇒ Object
25 26 27 |
# File 'lib/mattermost/resource_name.rb', line 25 def param_key "#{singular}_id".downcase.to_sym end |
#path ⇒ Object
21 22 23 |
# File 'lib/mattermost/resource_name.rb', line 21 def path plural.downcase end |
#plural ⇒ Object
17 18 19 |
# File 'lib/mattermost/resource_name.rb', line 17 def plural "#{@klass}s".downcase end |
#singular ⇒ Object
13 14 15 |
# File 'lib/mattermost/resource_name.rb', line 13 def singular @klass.downcase end |