Module: QUI::CommonHelpers::Model

Defined in:
lib/qui-common-helpers.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:nodoc:



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/qui-common-helpers.rb', line 40

def self.included(base) # :nodoc:
  base.extend ClassMethods
  
  def link_default_description
    if self.class.respond_to?(:link_default_description_field)
      send(self.class.link_default_description_field)
    else
      "#{self.class.human_name} ##{id}"
    end
  end
  
  def enum_human_value(attribute_name)
    self.class.enum_human_value(attribute_name, self.send(attribute_name))
  end
end

Instance Method Details

#enum_human_value(attribute_name) ⇒ Object



51
52
53
# File 'lib/qui-common-helpers.rb', line 51

def enum_human_value(attribute_name)
  self.class.enum_human_value(attribute_name, self.send(attribute_name))
end


43
44
45
46
47
48
49
# File 'lib/qui-common-helpers.rb', line 43

def link_default_description
  if self.class.respond_to?(:link_default_description_field)
    send(self.class.link_default_description_field)
  else
    "#{self.class.human_name} ##{id}"
  end
end