Method: Conjur::DSL2::Types::AttributeDefinition#attribute
- Defined in:
- lib/conjur/dsl2/types/base.rb
#attribute(attr, options = {}) ⇒ Object
This is the primary method used by concrete types to define their attributes.
attr
the singularized attribute name.
Options: type
a structured type to be constructed by the parser. If not provided, the type may be inferred from the attribute name (e.g. an attribute called :member is the type Member
). kind
the symbolic name of the type. Inferred from the type, if the type is provided. Otherwise it’s mandatory. singular
by default, attributes accept multiple values. This flag restricts the attribute to a single value only.
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/conjur/dsl2/types/base.rb', line 225 def attribute attr, = {} type = [:type] begin type ||= Conjur::DSL2::Types.const_get(attr.to_s.capitalize) rescue NameError end kind = [:kind] kind ||= type.short_name.downcase.to_sym if type raise "Attribute :kind must be defined, explicitly or inferred from :type" unless kind if [:singular] define_field attr, kind, type, [:dsl_accessor] else define_plural_field attr, kind, type, [:dsl_accessor] end end |