Sha256: 88e3985f348bb7715597de7b0e4e034579877e82f8b910591a98abe4a638312c

Contents?: true

Size: 772 Bytes

Versions: 6

Compression:

Stored size: 772 Bytes

Contents

require 'rubygems'
require './lib/ymdp/configuration/config'

class Thing
  include YMDP::Configuration::Helpers

  def self.configure
    setter = YMDP::Configuration::Setter.new
    
    yield setter
    
    @@paths = setter.paths
    @@servers = setter.servers
    
    setter.content_variables.each do |key, value|
      class_eval %(
        class << self
          attr_accessor :#{key}
        end
          
        self.#{key} = "#{value}"
      )
      
      eval %(
        def #{key}
          self.class.#{key}
        end
      )
    end
  end
end



Thing.configure do |config|
  config.add_content_variable :hello, "what"
  config.add_content_variable :yer_mom, "yeah"
end

t = Thing.new

puts Thing.hello
puts t.hello

puts Thing.yer_mom
puts t.yer_mom

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ymdp-0.1.10 test.rb
ymdp-0.1.9 test.rb
ymdp-0.1.8.1 test.rb
ymdp-0.1.8 test.rb
ymdp-0.1.7 test.rb
ymdp-0.1.6 test.rb