class Crudboy::Model

Attributes

active_record_model[RW]
columns[RW]
name[RW]
table_comment[RW]
table_name[RW]

Public Class Methods

new(active_record_model, table_name, table_comment) click to toggle source
# File lib/crudboy/model.rb, line 5
def initialize(active_record_model, table_name, table_comment)
  @active_record_model = active_record_model
  @name = @active_record_model.name
  @table_name = table_name
  @table_comment = table_comment
  @columns = active_record_model.columns.map { |c| Column.new(c, c.name == active_record_model.primary_key) }
end

Public Instance Methods

method_missing(method, *args, **options, &block) click to toggle source
Calls superclass method
# File lib/crudboy/model.rb, line 47
def method_missing(method, *args, **options, &block)
  if active_record_model.respond_to?(method)
    active_record_model.send(method, *args, **options, &block)
  else
    super
  end
end
primary_column() click to toggle source
# File lib/crudboy/model.rb, line 13
def primary_column
  columns.find { |c| c.name == active_record_model.primary_key }
end
regular_columns() click to toggle source
# File lib/crudboy/model.rb, line 17
def regular_columns
  columns.reject { |c| c.name == active_record_model.primary_key }
end