Method: Charisma::Characterization#has

Defined in:
lib/charisma/characterization.rb

#has(name, options = {}, &blk) ⇒ Object

Define a characteristic.

This is used within Charisma::Base::ClassMethods#characterize blocks to curate attributes on a class. Internally, a Charisma::Characteristic is created to store the definition.

Parameters:

  • (Symbol)
  • name (Symbol)

    The name of the characteristic. The method with this name will be called on the characterized object to retrieve its raw value.

  • options (Hash) (defaults to: {})

    The options hash.

  • [Symbol] (Hash)

    a customizable set of options

  • [Class, (Hash)

    a customizable set of options

  • [Proc] (Hash)

    a customizable set of options

See Also:



19
20
21
22
# File 'lib/charisma/characterization.rb', line 19

def has(name, options = {}, &blk)
  name = name.to_sym
  self[name] = Characteristic.new(name, options, &blk)
end