module CommandServiceObject::ModelHelper
Public Instance Methods
allowed_column_types()
click to toggle source
# File lib/command_service_object/helpers/model_helper.rb, line 41 def allowed_column_types { string: 'String', bigint: 'Integer', integer: 'Integer', decimal: 'Float', boolean: 'Boolean', datetime: 'DateTime' } end
ignored_column_names()
click to toggle source
# File lib/command_service_object/helpers/model_helper.rb, line 33 def ignored_column_names %w[ created_at updated_at encrypted_password ] end
model_attributes()
click to toggle source
# File lib/command_service_object/helpers/model_helper.rb, line 15 def model_attributes default_attr = { REPLACE_ME: String } return default_attr if model_class.nil? || model_class.try(:columns_hash).nil? attrs = {} model_class.columns_hash.each do |k, v| next if ignored_column_names.include?(k) type = allowed_column_types[v.type] next if type.nil? attrs[k] = type end attrs end
model_class()
click to toggle source
# File lib/command_service_object/helpers/model_helper.rb, line 9 def model_class Object.const_get(model_name) rescue StandardError nil end
model_name()
click to toggle source
# File lib/command_service_object/helpers/model_helper.rb, line 5 def model_name name.camelize end