Module: Microservice::Concerns::EntityModel

Extended by:
ActiveSupport::Concern
Defined in:
app/models/microservice/concerns/entity_model.rb

Overview

Example of migration:

 create_table :table_name, force: true do |t|
   t.string :name, null: false
   t.text :description, null: true
   t.boolean :active, null: false, default: true

   t.references :author, null: false
   t.references :updated_by, null: true
   t.timestamps null: false
end

Instance Method Summary collapse

Instance Method Details

#class_route_arrayObject



104
105
106
# File 'app/models/microservice/concerns/entity_model.rb', line 104

def class_route_array
  self.class.class_route_array
end

#css_class(options = {}) ⇒ Object



84
85
86
# File 'app/models/microservice/concerns/entity_model.rb', line 84

def css_class(options = {})
  self.class.css_class(options)
end

#last_touch_byObject



112
113
114
# File 'app/models/microservice/concerns/entity_model.rb', line 112

def last_touch_by
  updated_by || author
end

#model_route_arrayObject



100
101
102
# File 'app/models/microservice/concerns/entity_model.rb', line 100

def model_route_array
  [self.namespace, self.parent_entity, polymorphic_class]
end

#parent_entityObject



88
89
90
# File 'app/models/microservice/concerns/entity_model.rb', line 88

def parent_entity
  send(parent_entity_symbol) if parent_entity_symbol
end

#parent_entity=(value) ⇒ Object



92
93
94
# File 'app/models/microservice/concerns/entity_model.rb', line 92

def parent_entity=(value)
  send(parent_entity_symbol.to_s + '=', value) if parent_entity_symbol
end

#polymorphic_classObject



96
97
98
# File 'app/models/microservice/concerns/entity_model.rb', line 96

def polymorphic_class
  self.becomes(self.class.base_class)
end

#to_form_pathObject



108
109
110
# File 'app/models/microservice/concerns/entity_model.rb', line 108

def to_form_path
  self.class._to_form_path
end