module ActiveEntity::ModelSchema::ClassMethods
Public Instance Methods
type_for_attribute(attr_name, &block)
click to toggle source
Returns the type of the attribute with the given name, after applying all modifiers. This method is the only valid source of information for anything related to the types of a model's attributes. This method will access the database and load the model's schema if it is required.
The return value of this method will implement the interface described by ActiveModel::Type::Value (though the object itself may not subclass it).
attr_name
The name of the attribute to retrieve the type for. Must be a string or a symbol.
# File lib/active_entity/model_schema.rb, line 44 def type_for_attribute(attr_name, &block) attr_name = attr_name.to_s if block attribute_types.fetch(attr_name, &block) else attribute_types[attr_name] end end
Protected Instance Methods
initialize_load_schema_monitor()
click to toggle source
# File lib/active_entity/model_schema.rb, line 60 def initialize_load_schema_monitor @load_schema_monitor = Monitor.new end
Private Instance Methods
inherited(child_class)
click to toggle source
Calls superclass method
# File lib/active_entity/model_schema.rb, line 66 def inherited(child_class) super child_class.initialize_load_schema_monitor end
load_schema()
click to toggle source
# File lib/active_entity/model_schema.rb, line 75 def load_schema return if schema_loaded? @load_schema_monitor.synchronize do return if defined?(@load_schema_invoked) && @load_schema_invoked load_schema! @schema_loaded = true end end
load_schema!()
click to toggle source
# File lib/active_entity/model_schema.rb, line 85 def load_schema! @load_schema_invoked = true end
reload_schema_from_cache()
click to toggle source
# File lib/active_entity/model_schema.rb, line 89 def reload_schema_from_cache @attribute_types = nil @default_attributes = nil @attributes_builder = nil @schema_loaded = false @load_schema_invoked = false @attribute_names = nil @yaml_encoder = nil direct_descendants.each do |descendant| descendant.send(:reload_schema_from_cache) end end
schema_loaded?()
click to toggle source
# File lib/active_entity/model_schema.rb, line 71 def schema_loaded? defined?(@schema_loaded) && @schema_loaded end