Class: Charisma::Characterization

Inherits:
Hash
  • Object
show all
Includes:
Blockenspiel::DSL
Defined in:
lib/charisma/characterization.rb

Overview

Stores the set of characteristics defined on a class.

Typically this is created with Charisma::Base::ClassMethods#characterize, and characteristics defined within it by the ensuing block.

Instance Method Summary collapse

Instance Method Details

#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