Class: Jetski::Model

Inherits:
Object
  • Object
show all
Extended by:
Database::Base, Helpers::Delegatable, Helpers::Generic, Attributes
Includes:
Helpers::Generic, CrudHelpers
Defined in:
lib/jetski/model.rb,
lib/jetski/model/attributes.rb,
lib/jetski/model/crud_helpers.rb

Defined Under Namespace

Modules: Attributes, CrudHelpers

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Attributes

attribute_names, attributes, db_attribute_values

Methods included from Helpers::Generic

pluralize_string

Methods included from Database::Base

create_table_sql, db, sql_data_type

Methods included from Helpers::Delegatable

delegate

Methods included from CrudHelpers

#destroy!, included

Constructor Details

#initialize(**args) ⇒ Model



7
8
9
# File 'lib/jetski/model.rb', line 7

def initialize(**args)
  @virtual_attributes = args
end

Class Method Details

.pluralized_table_nameObject



29
30
31
# File 'lib/jetski/model.rb', line 29

def pluralized_table_name
  pluralize_string(table_name)
end

.table_nameObject



25
26
27
# File 'lib/jetski/model.rb', line 25

def table_name
  self.to_s.downcase
end

Instance Method Details

#inspectObject



11
12
13
14
15
16
17
18
19
# File 'lib/jetski/model.rb', line 11

def inspect
  inspect_str = "#<#{self.class.to_s}:#{object_id}"
  self.class.attribute_names.each do |attribute_name|
    attribute_value = @virtual_attributes[attribute_name]
    inspect_str += " #{attribute_name}=\"#{attribute_value}\""
  end
  inspect_str += ">"
  inspect_str
end