Module: Characterizable

Defined in:
lib/characterizable.rb,
lib/characterizable/base.rb,
lib/characterizable/snapshot.rb,
lib/characterizable/better_hash.rb,
lib/characterizable/characteristic.rb

Defined Under Namespace

Modules: ClassMethods Classes: Base, BetterHash, Characteristic, CharacteristicAlreadyDefined, Snapshot

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



22
23
24
25
# File 'lib/characterizable.rb', line 22

def self.included(klass)
  klass.cattr_accessor :characterizable_base
  klass.extend ClassMethods
end

Instance Method Details

#characteristicsObject



27
28
29
# File 'lib/characterizable.rb', line 27

def characteristics
  @_characteristics ||= Snapshot.new self
end

#display_characteristic(name) ⇒ Object



35
36
37
38
# File 'lib/characterizable.rb', line 35

def display_characteristic(name)
  characteristic = self.class.characteristics[name]
  characteristic.display(characteristics) if characteristic
end

#expire_snapshot!Object



31
32
33
# File 'lib/characterizable.rb', line 31

def expire_snapshot!
  @_characteristics = nil
end