Class: Hashblue::API::Model::Name

Inherits:
String
  • Object
show all
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

Instance Method Summary collapse

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

#collectionObject (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

#elementObject (readonly)

Returns the value of attribute element.



7
8
9
# File 'lib/hashblue/api/model.rb', line 7

def element
  @element
end

#humanObject (readonly)

Returns the value of attribute human.



7
8
9
# File 'lib/hashblue/api/model.rb', line 7

def human
  @human
end

#partial_pathObject (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

#pluralObject (readonly)

Returns the value of attribute plural.



7
8
9
# File 'lib/hashblue/api/model.rb', line 7

def plural
  @plural
end

#singularObject (readonly)

Returns the value of attribute singular.



7
8
9
# File 'lib/hashblue/api/model.rb', line 7

def singular
  @singular
end