Module: IIRC::Configure

Included in:
Bot
Defined in:
lib/iirc/modules/configure.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(m) ⇒ Object



3
4
5
6
# File 'lib/iirc/modules/configure.rb', line 3

def self.included(m)
  require 'set'
  m.extend ClassMethods
end

Instance Method Details

#configure!Object



23
24
25
26
27
28
29
30
31
# File 'lib/iirc/modules/configure.rb', line 23

def configure!
  for action in configure_actions
    if action.is_a? Symbol
      send(action)
    else
      instance_exec(&action)
    end
  end
end

#configure_actionsObject (private)



33
34
35
36
37
38
39
40
# File 'lib/iirc/modules/configure.rb', line 33

private def configure_actions
  singleton_class.ancestors
    .filter   { |m| m.respond_to?(:configure_actions) }
    .flat_map { |m| m.configure_actions.to_a }
    .concat((methods + private_methods).grep(/^configure_(?!actions)/))
    .compact
    .uniq
end

#initializeObject



18
19
20
21
# File 'lib/iirc/modules/configure.rb', line 18

def initialize(*)
  super if defined? super
  configure!
end