Class: Vkontakte::Config
- Inherits:
-
Hash
- Object
- Hash
- Vkontakte::Config
- Defined in:
- lib/vkontakte/config.rb
Class Method Summary collapse
-
.hash_accessor(*names) ⇒ Object
Creates an accessor that simply sets and reads a key in the hash:.
Instance Method Summary collapse
-
#initialize(other = {}) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(other = {}) ⇒ Config
Returns a new instance of Config.
29 30 31 32 33 34 35 36 |
# File 'lib/vkontakte/config.rb', line 29 def initialize(other={}) merge!(other) self[:app_id] ||= "Vkontakte API ID" self[:app_secret] ||= "Vkontakte APP SECRET" self[:format] ||= :json self[:debug] ||= false self[:logger] ||= nil end |
Class Method Details
.hash_accessor(*names) ⇒ Object
Creates an accessor that simply sets and reads a key in the hash:
class Config < Hash
hash_accessor :routes, :secret_key, :service_number, :project_name
end
config = Config.new config.routes = ‘/posts/message’ config #=> ‘/posts/message’
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/vkontakte/config.rb', line 13 def self.hash_accessor(*names) #:nodoc: names.each do |name| class_eval <<-METHOD, __FILE__, __LINE__ + 1 def #{name} self[:#{name}] end def #{name}=(value) self[:#{name}] = value end METHOD end end |