Sha256: a173ad32a825b922f2eab7c368689b7a033be8b20706a19d0a7ccf9483eb27ec
Contents?: true
Size: 887 Bytes
Versions: 1
Compression:
Stored size: 887 Bytes
Contents
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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
axle_attributes-1.13.2 | lib/axle_attributes/child_definition.rb |