Sha256: 298d9681e572458a3a2bbb5cfa01980364244de0acf3b57f4966c397a1b9b5cc
Contents?: true
Size: 563 Bytes
Versions: 1
Compression:
Stored size: 563 Bytes
Contents
require 'lazy_const' class FeatureDefinitions extend LazyConst attr_reader :opts, :test_proc def self.define_feature(name, opts = {}, &block) lazy_const(name){ new(opts, block.to_proc) } end def initialize(opts, proc) @opts = opts @test_proc = proc end def self.context=(context) @@context = context end def context @@context end def enabled?(&block) args = opts[:using].map { |sym| context.public_send(sym) } test_proc.call(*args).tap do |verdict| yield if block_given? and verdict end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
feature_definitions-0.2.0 | lib/feature_definitions.rb |