RubyGems Navigation menu

config_accessor 0.0.3

Synopsys

Class-level configuration DSL

Installation

gem install config_accessor

Examples

require 'config_accessor'

class Remote
  configurable!

  config_accessor :host, :default => "localhost"
  config_accessor :port, :default => "80", :transform => :to_i
  config_accessor :proxy_host, :proxy_port
end

class Local < Remote
  config_accessor :l_port
end

Remote.host        # => "localhost"
Remote.port        # => 80
Remote.proxy_host  # => nil

r = Remote.new

r.port = "81"
r.port             # => 81
Remote.port        # => 80
Remote.port = 82

# next expressions are equivalent
r.port             # => 81
r.config[:port]    # => 81
r.config["port"]   # => 81
r.config.port      # => 81

# It supports inheritance, subclasses cannot change superclasses configurations
Local.port         # => 80

# You can do it with +configure+ method
Local.configure do
  port 81
end

# or
Local.configure do |config|
  config.port 81
end

版本列表:

  1. 0.0.3 - December 10, 2011 (7.5 KB)
  2. 0.0.2 - December 10, 2011 (7.0 KB)
顯示所有版本(共 3)

Development 相依性套件 (1):

  • rspec >= 0
  • 擁有者:

    作者:

    • Alexei Mikhailov

    SHA 256 checksum:

    6a7dc9486f947fc1917b132988ff83eac375f54f7043ff0acfde13e7612531d6

    總下載次數 6,138

    這個版本 3,486

    Gemfile:
    = 複製 已複製

    安裝:
    =

    License:

    Ruby 版本需求:

    相關連結: