Module: Contextualize::ClassMethods

Defined in:
lib/contextualize.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#context_mapObject (readonly)

Returns the value of attribute context_map.



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

def context_map
  @context_map
end

Instance Method Details

#context(name, *constants) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/contextualize.rb', line 10

def context name, *constants
  @context_map ||= {}
  context_modules = if constants.flatten.empty?
    const_by_convention(name)
  else
    select_modules constants
  end
  @context_map[name.to_sym] = context_modules
end

#contexts(*names) ⇒ Object



20
21
22
23
24
# File 'lib/contextualize.rb', line 20

def contexts *names
  names.flatten.each do |name|
    context name, const_by_convention(name)
  end
end