Module: Granite::Form::Model::Primary::ClassMethods
- Defined in:
- lib/granite/form/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
34 35 36 |
# File 'lib/granite/form/model/primary.rb', line 34 def has_primary_attribute? # rubocop:disable Naming/PredicateName has_attribute? _primary_name end |
#primary(*args) ⇒ Object Also known as: primary_attribute
22 23 24 25 26 27 28 29 30 |
# File 'lib/granite/form/model/primary.rb', line 22 def primary(*args) = args. self._primary_name = (args.first.presence || Granite::Form.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
38 39 40 |
# File 'lib/granite/form/model/primary.rb', line 38 def primary_name _primary_name end |