Module: ActiveData::Model::Primary::ClassMethods
- Defined in:
- lib/active_data/model/primary.rb
Instance Method Summary collapse
-
#has_primary_attribute? ⇒ Boolean
rubocop:disable Naming/PredicateName.
- #primary(*args) ⇒ Object (also: #primary_attribute)
- #primary_name ⇒ Object
Instance Method Details
#has_primary_attribute? ⇒ Boolean
rubocop:disable Naming/PredicateName
32 33 34 |
# File 'lib/active_data/model/primary.rb', line 32 def has_primary_attribute? # rubocop:disable Naming/PredicateName has_attribute? _primary_name end |
#primary(*args) ⇒ Object Also known as: primary_attribute
21 22 23 24 25 26 27 28 29 |
# File 'lib/active_data/model/primary.rb', line 21 def primary(*args) = args. self._primary_name = (args.first.presence || ActiveData.primary_attribute).to_s unless has_attribute?(_primary_name) [:type] = args.second if args.second attribute _primary_name, .presence || DEFAULT_PRIMARY_ATTRIBUTE_OPTIONS.call end alias_attribute :primary_attribute, _primary_name end |
#primary_name ⇒ Object
36 37 38 |
# File 'lib/active_data/model/primary.rb', line 36 def primary_name _primary_name end |