Sha256: c6a9a21522fa56431b55217bb7c9a2665123b58a42dd681647d3602d6bf47f40

Contents?: true

Size: 692 Bytes

Versions: 3

Compression:

Stored size: 692 Bytes

Contents

module Recess::Outside
  module ClassMethods
    def recess_group(name, &block)
      @recess_groups ||= {}
      @recess_groups[name.to_s] = block
    end
    
    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
  end
end

Object.send :include, Recess::Outside::ClassMethods

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
recess-0.0.3 lib/recess/outside.rb
recess-0.0.2 lib/recess/outside.rb
recess-0.0.1 lib/recess/outside.rb