Class: Infold::Model

Inherits:
ApplicationRecord show all
Defined in:
app/models/infold/model.rb

Instance Method Summary collapse

Instance Method Details

#locale_or_nameObject



27
28
29
# File 'app/models/infold/model.rb', line 27

def locale_or_name
  locale.presence || name
end

#name_pluralizeObject



31
32
33
# File 'app/models/infold/model.rb', line 31

def name_pluralize
  name.to_s.underscore.pluralize
end

#self_and_association_modelsObject



22
23
24
25
# File 'app/models/infold/model.rb', line 22

def self_and_association_models
  order = "CASE WHEN id = #{id} THEN 0 ELSE id END"
  self.class.where(id: [id] + child_model_associations.map(&:model_id)).order(Arel.sql(order))
end

#set_name_from_table_nameObject



35
36
37
# File 'app/models/infold/model.rb', line 35

def set_name_from_table_name
  self.name = table_name&.singularize&.camelize
end