Sha256: fed776813e75968816d86b0f7f3c6dfcda8d0e983eb71cfac0e185a6e3e45dfb

Contents?: true

Size: 651 Bytes

Versions: 1

Compression:

Stored size: 651 Bytes

Contents

module Surrounded
  module Context
    module Initializing
      # Shorthand for creating an instance level initialize method which
      # handles the mapping of the given arguments to their named role.
      def initialize(*setup_args)
        private_attr_reader(*setup_args)
      
        mod = Module.new
        line = __LINE__
        mod.class_eval "
          def initialize(#{setup_args.join(',')})
            @role_map = RoleMap.new
            map_roles(#{setup_args.to_s}.zip([#{setup_args.join(',')}]))
          end
        ", __FILE__, line
        const_set("ContextInitializer", mod)
        include mod
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
surrounded-0.9.1 lib/surrounded/context/initializing.rb