Module: HasBehaviour::ClassMethods

Defined in:
lib/has_behaviour.rb

Instance Method Summary collapse

Instance Method Details

#has_behaviour(klass, behaviour_name: nil) ⇒ Object


8
9
10
11
# File 'lib/has_behaviour.rb', line 8

def has_behaviour(klass, behaviour_name: nil)
  @registered_behaviours ||= {}
  @registered_behaviours[behaviour_name || klass.name] = klass
end

#has_behaviour?(behaviour_name) ⇒ Boolean

Returns:

  • (Boolean)

13
14
15
# File 'lib/has_behaviour.rb', line 13

def has_behaviour?(behaviour_name)
  @registered_behaviours.key?(behaviour_name)
end

#registered_behavioursObject


21
22
23
# File 'lib/has_behaviour.rb', line 21

def registered_behaviours
  @registered_behaviours.keys
end

#with_behaviour(behaviour_name) ⇒ Object


17
18
19
# File 'lib/has_behaviour.rb', line 17

def with_behaviour(behaviour_name)
  @registered_behaviours.fetch(behaviour_name)
end