Sha256: 83cc9e10241ac270607d56588256f7411b1fef5e2e34218fcbb1cb8fc6a1bcf0

Contents?: true

Size: 823 Bytes

Versions: 5

Compression:

Stored size: 823 Bytes

Contents

module Sprinkle
  #--
  # TODO: Possible documentation?
  #++
  module Configurable #:nodoc:
    attr_accessor :delivery
    
    def defaults(deployment)
      defaults = deployment.defaults[self.class.name.split(/::/).last.downcase.to_sym]
      self.instance_eval(&defaults) if defaults
      @delivery = deployment.style
    end
    
    def assert_delivery
      raise 'Unknown command delivery target' unless @delivery
    end
    
    def method_missing(sym, *args, &block)
      unless args.empty? # mutate if not set
        @options ||= {}
        @options[sym] = args unless @options[sym]
      end

      @options[sym] || @package.send(sym, *args, &block) # try the parents options if unknown
    end
    
    # both nil and false should return false
    def option?(sym)
      !!@options[sym]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sprinkle-0.5.2 lib/sprinkle/configurable.rb
sprinkle-0.5.1.1 lib/sprinkle/configurable.rb
sprinkle-0.5.1 lib/sprinkle/configurable.rb
sprinkle-0.5.0 lib/sprinkle/configurable.rb
sprinkle-0.5.0.rc1 lib/sprinkle/configurable.rb