Class: HasPermalink::Utilities

Inherits:
Object
  • Object
show all
Defined in:
lib/utilities.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#klassObject

Returns the value of attribute klass.



3
4
5
# File 'lib/utilities.rb', line 3

def klass
  @klass
end

#model_nameObject

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



20
21
22
# File 'lib/utilities.rb', line 20

def generate_permalinks
  @klass.generate_permalinks
end

#get_classObject



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