Module: HasBehaviour::ClassMethods

Defined in:
lib/has_behaviour.rb

Instance Method Summary collapse

Instance Method Details

#has_behaviour(klass, behaviour_name: nil) ⇒ Object



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

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

#has_behaviour?(behaviour_name) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#registered_behavioursObject



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

def registered_behaviours
  @registered_behaviours.keys
end

#with_behaviour(behaviour_name) ⇒ Object



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

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