module LightweightAttributes::BaseClassMethods
Public Instance Methods
attributes_builder()
click to toggle source
Calls superclass method
# File lib/lightweight_attributes/base_class_methods.rb, line 16 def attributes_builder if attributes_to_define_after_schema_loads.empty? unless defined?(@attributes_builder) && @attributes_builder defaults = _default_attributes.except(*(column_names - [primary_key])) @attributes_builder = LightweightAttributes::AttributeSet::Builder.new(attribute_types, defaults) end @attributes_builder else super end end
load_schema!()
click to toggle source
Calls superclass method
# File lib/lightweight_attributes/base_class_methods.rb, line 28 def load_schema! super include BaseMethods if attributes_to_define_after_schema_loads.empty? end
Private Instance Methods
define_default_attribute(name, value, type, from_user:)
click to toggle source
TODO: maybe we need to properly handle other non-nil values
Calls superclass method
# File lib/lightweight_attributes/base_class_methods.rb, line 34 def define_default_attribute(name, value, type, from_user:) super if attributes_to_define_after_schema_loads.any? if value.nil? || (value == ActiveRecord::Attributes::ClassMethods.const_get(:NO_DEFAULT_PROVIDED)) _default_attributes[name] = nil else super end end