Sha256: c843e544353ee7c02420939d9cba09845e853c92a48c606aae9b5c0a9cc84e37

Contents?: true

Size: 427 Bytes

Versions: 1

Compression:

Stored size: 427 Bytes

Contents

require 'lazy_const'

class FeatureDefinitions
  extend LazyConst

  def self.define_feature(name, opts = {}, &block)
    lazy_const(name){ new(opts, &block) }
  end

  def initialize(opts = {}, &block)
    @opts = opts
    @proc = block.to_proc
  end

  def self.context=(context)
    @@context = context
  end

  def enabled?
    args = @opts[:using].map { |sym| @@context.public_send(sym) }
    @proc.call(*args)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
feature_definitions-0.1.1 lib/feature_definitions.rb