Class: Bizside::Config
- Inherits:
-
Object
- Object
- Bizside::Config
- Includes:
- Bizside::Configurations::Mail, Bizside::Configurations::Prefix, Bizside::Configurations::Storage
- Defined in:
- lib/bizside/config.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#empty? ⇒ Boolean
Hash継承時代での互換維持のために実装.
-
#initialize(hash = {}) ⇒ Config
constructor
A new instance of Config.
- #method_missing(name, *args) ⇒ Object
- #to_h ⇒ Object
-
#to_hash ⇒ Object
オブジェクトの Hash への暗黙の変換が必要なときに内部で呼ばれるメソッド Hash継承時代での互換維持のために実装。 なお、Hashの継承時代でも @hash を活用していたので、空ハッシュを返す.
Methods included from Bizside::Configurations::Storage
Methods included from Bizside::Configurations::Prefix
Methods included from Bizside::Configurations::Mail
#default_url_options, #mail, #smtp_settings
Constructor Details
#initialize(hash = {}) ⇒ Config
Returns a new instance of Config.
11 12 13 |
# File 'lib/bizside/config.rb', line 11 def initialize(hash = {}) @hash = hash || {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
Instance Method Details
#[](key) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/bizside/config.rb', line 15 def [](key) key = key.to_s return (@hash[key[0..-2]] ? true : false) if key.end_with?('?') ret = @hash[key] if ret.nil? ret = self.class.new elsif ret.is_a?(Hash) ret = self.class.new(ret) end ret end |
#[]=(key, value) ⇒ Object
29 30 31 32 |
# File 'lib/bizside/config.rb', line 29 def []=(key, value) value = self.class.new(value) if value.is_a?(Hash) @hash[key.to_s] = value end |
#empty? ⇒ Boolean
Hash継承時代での互換維持のために実装
39 40 41 |
# File 'lib/bizside/config.rb', line 39 def empty? @hash.empty? end |
#to_h ⇒ Object
34 35 36 |
# File 'lib/bizside/config.rb', line 34 def to_h @hash.dup end |
#to_hash ⇒ Object
オブジェクトの Hash への暗黙の変換が必要なときに内部で呼ばれるメソッドHash継承時代での互換維持のために実装。なお、Hashの継承時代でも @hash を活用していたので、空ハッシュを返す
47 48 49 50 |
# File 'lib/bizside/config.rb', line 47 def to_hash warn "DEPRECATION WARNING: #{__method__} is deprecated and will be removed." {} end |