Sha256: 946c581345a3d0adbe11c7723daa6c4411d87ac73a66b326f122e3e8f0cf0d21

Contents?: true

Size: 733 Bytes

Versions: 8

Compression:

Stored size: 733 Bytes

Contents

module Prospectus
  ##
  # Define a state object that supports modular checks
  class State
    attr_accessor :value

    def initialize(params = {})
      @options = params
    end

    def self.from_block(params = {}, state = nil, &block)
      state ||= State.new(params)
      dsl = StateDSL.new(state, params)
      dsl.instance_eval(&block)
      dsl.load!
      state
    end
  end

  ##
  # DSL for wrapping eval of states
  class StateDSL
    def initialize(state, params)
      @state = state
      @options = params
    end

    def method_missing(method, *args, &block)
      return super if @module
      @module = Prospectus.modules.find(method)
      return super unless @module
      extend @module
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
prospectus-0.0.15 lib/prospectus/state.rb
prospectus-0.0.13 lib/prospectus/state.rb
prospectus-0.0.12 lib/prospectus/state.rb
prospectus-0.0.11 lib/prospectus/state.rb
prospectus-0.0.10 lib/prospectus/state.rb
prospectus-0.0.9 lib/prospectus/state.rb
prospectus-0.0.8 lib/prospectus/state.rb
prospectus-0.0.6 lib/prospectus/state.rb