Module: Recess::Outside::ClassMethods

Defined in:
lib/recess/outside.rb

Instance Method Summary collapse

Instance Method Details

#outside(what, *args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/recess/outside.rb', line 8

def outside(what, *args)
  options = args.last.is_a?(::Hash) ? args.pop : {}
  object_clazz = what
  
  groups = object_clazz.instance_variable_get("@recess_groups")
  raise "Missing recess_groups directive in #{object_clazz}" unless groups
  
  args.each do |trait_name|
    macro = groups[trait_name.to_s]
    raise "Missing recess group name: #{trait_name}" unless macro
    
    class_exec(&macro)
  end
end

#recess_group(name, &block) ⇒ Object



3
4
5
6
# File 'lib/recess/outside.rb', line 3

def recess_group(name, &block)
  @recess_groups ||= {}
  @recess_groups[name.to_s] = block
end