105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
# File 'lib/sql_view.rb', line 105
def ClassBuilder.create_model(parent)
class_name = "#{parent}Model"
klass = Class.new(ActiveRecord::Base) do
def self.model_name
ActiveModel::Name.new(self, nil, parent.view_name)
end
def readonly?
true
end
self.table_name = parent.view_name
self.inheritance_column = nil
end
if parent.sql_view_options[:extend_model_with].present?
klass.class_eval(&parent.sql_view_options[:extend_model_with])
end
klass.class_eval %Q{
def self.name
"#{class_name}"
end
}
Object.const_set(class_name, klass) unless const_defined?(class_name)
Object.const_get(class_name)
end
|