Class: WechatGate::Config
- Inherits:
-
Object
- Object
- WechatGate::Config
- Includes:
- Media, Menu, Message, Oauth, SendMessage, Tokens::AccessToken, Tokens::Ext, Tokens::JsapiTicket, User
- Defined in:
- lib/wechat_gate/config.rb
Instance Attribute Summary collapse
-
#app_config_name ⇒ Object
readonly
Returns the value of attribute app_config_name.
-
#output_type ⇒ Object
readonly
Returns the value of attribute output_type.
-
#specs ⇒ Object
readonly
Returns the value of attribute specs.
Instance Method Summary collapse
-
#initialize(app_config_name, config_file = nil) {|_self| ... } ⇒ Config
constructor
A new instance of Config.
Methods included from SendMessage
Methods included from Message
Methods included from Media
Methods included from Menu
Methods included from User
Methods included from Oauth
#oauth2_access_token, #oauth2_access_token_valid?, #oauth2_entrance_url, #oauth2_refresh_access_token, #oauth2_user
Methods included from Tokens::Ext
#generate_js_request_params, #write_token_to_file
Methods included from Tokens::JsapiTicket
Methods included from Tokens::AccessToken
Constructor Details
#initialize(app_config_name, config_file = nil) {|_self| ... } ⇒ Config
Returns a new instance of Config.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/wechat_gate/config.rb', line 32 def initialize app_config_name, config_file = nil unless config_file if defined?(Rails) config_file = "#{Rails.root}/config/wechat.yml" end end raise Exception::ConfigException, "no wechat configuration file found!" unless config_file unless File.exists?(config_file) raise Exception::ConfigException, "configuration file does not exist!" end config_text = ERB.new(File.read(config_file)).result configs = YAML.load(config_text) unless configs[app_config_name] raise Exception::ConfigException, "no configuration found for app: #{app_config_name}!" end @specs = if defined?(Rails) configs[app_config_name][Rails.env] || configs[app_config_name] else configs[app_config_name] end @app_config_name = app_config_name yield(self) if block_given? end |
Instance Attribute Details
#app_config_name ⇒ Object (readonly)
Returns the value of attribute app_config_name.
18 19 20 |
# File 'lib/wechat_gate/config.rb', line 18 def app_config_name @app_config_name end |
#output_type ⇒ Object (readonly)
Returns the value of attribute output_type.
20 21 22 |
# File 'lib/wechat_gate/config.rb', line 20 def output_type @output_type end |
#specs ⇒ Object (readonly)
Returns the value of attribute specs.
19 20 21 |
# File 'lib/wechat_gate/config.rb', line 19 def specs @specs end |