Sha256: 3800eaea5ef7bfd221fc431475ab34dc466dea75320ab125cd9dcb207c6ec9e8
Contents?: true
Size: 971 Bytes
Versions: 7
Compression:
Stored size: 971 Bytes
Contents
module Vkontakte class Config < Hash # 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[:routes] #=> '/posts/message' # 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 hash_accessor :app_id, :app_secret, :debug, :logger, :format 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 end end
Version data entries
7 entries across 7 versions & 1 rubygems