Class: Hashblue::API::Model::Name
- Inherits:
-
String
- Object
- String
- Hashblue::API::Model::Name
- Defined in:
- lib/hashblue/api/model.rb
Overview
Stolen from ActiveModel to get around incompatabilities between ActiveSupport 2.3.5 and ActiveModel 3.0
Instance Attribute Summary collapse
-
#collection ⇒ Object
(also: #cache_key)
readonly
Returns the value of attribute collection.
-
#element ⇒ Object
readonly
Returns the value of attribute element.
-
#human ⇒ Object
readonly
Returns the value of attribute human.
-
#partial_path ⇒ Object
readonly
Returns the value of attribute partial_path.
-
#plural ⇒ Object
readonly
Returns the value of attribute plural.
-
#singular ⇒ Object
readonly
Returns the value of attribute singular.
Instance Method Summary collapse
-
#initialize(name) ⇒ Name
constructor
A new instance of Name.
Constructor Details
#initialize(name) ⇒ Name
Returns a new instance of Name.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/hashblue/api/model.rb', line 10 def initialize(name) super(name) @klass = name @singular = ActiveSupport::Inflector.underscore(self).tr('/', '_').freeze @plural = ActiveSupport::Inflector.pluralize(@singular).freeze @element = ActiveSupport::Inflector.underscore(ActiveSupport::Inflector.demodulize(self)).freeze @human = ActiveSupport::Inflector.humanize(@element).freeze @collection = ActiveSupport::Inflector.tableize(self).freeze @partial_path = "#{@collection}/#{@element}".freeze end |
Instance Attribute Details
#collection ⇒ Object (readonly) Also known as: cache_key
Returns the value of attribute collection.
7 8 9 |
# File 'lib/hashblue/api/model.rb', line 7 def collection @collection end |
#element ⇒ Object (readonly)
Returns the value of attribute element.
7 8 9 |
# File 'lib/hashblue/api/model.rb', line 7 def element @element end |
#human ⇒ Object (readonly)
Returns the value of attribute human.
7 8 9 |
# File 'lib/hashblue/api/model.rb', line 7 def human @human end |
#partial_path ⇒ Object (readonly)
Returns the value of attribute partial_path.
7 8 9 |
# File 'lib/hashblue/api/model.rb', line 7 def partial_path @partial_path end |
#plural ⇒ Object (readonly)
Returns the value of attribute plural.
7 8 9 |
# File 'lib/hashblue/api/model.rb', line 7 def plural @plural end |
#singular ⇒ Object (readonly)
Returns the value of attribute singular.
7 8 9 |
# File 'lib/hashblue/api/model.rb', line 7 def singular @singular end |