module AxleAttributes class ChildDefinition < ::AxleAttributes::Definition attr_accessor :nested_path setup do setup_storage! unless name == 'id' setup_versioning! end def display_name human = model.model_name.human human = human.pluralize if nested_path "#{human}: #{super}" end def canonical_name @canonical_name ||= "#{model.model_name.send(nested_path ? :plural : :singular)}.#{name}" end private def setup_storage! if type storage_options = case type when :text {type: :string} else options.slice(:type, :default) end model.attribute(name, storage_options) end end def setup_versioning! if versioned? model.add_versioned_attribute name end end end end