Class: HasPermalink::Utilities
- Inherits:
-
Object
- Object
- HasPermalink::Utilities
- Defined in:
- lib/utilities.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#model_name ⇒ Object
Returns the value of attribute model_name.
Instance Method Summary collapse
- #generate_permalinks ⇒ Object
- #get_class ⇒ Object
-
#initialize(model_name) ⇒ Utilities
constructor
A new instance of Utilities.
Constructor Details
#initialize(model_name) ⇒ Utilities
Returns a new instance of Utilities.
5 6 7 8 |
# File 'lib/utilities.rb', line 5 def initialize(model_name) @model_name = model_name @klass = self.get_class end |
Instance Attribute Details
#klass ⇒ Object
Returns the value of attribute klass.
3 4 5 |
# File 'lib/utilities.rb', line 3 def klass @klass end |
#model_name ⇒ Object
Returns the value of attribute model_name.
3 4 5 |
# File 'lib/utilities.rb', line 3 def model_name @model_name end |
Instance Method Details
#generate_permalinks ⇒ Object
20 21 22 |
# File 'lib/utilities.rb', line 20 def generate_permalinks @klass.generate_permalinks end |
#get_class ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/utilities.rb', line 10 def get_class if @model_name.include?('::') @model_name.split('::').inject(Object) do |mod, class_name| mod.const_get(class_name) end else Object.const_get(@model_name) end end |