Class: WechatConfig
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- WechatConfig
- Defined in:
- lib/generators/wechat/templates/app/models/wechat_config.rb
Overview
Used by wechat gems, do not rename WechatConfig to other name, Feel free to inherit from other class like ActiveModel::Model
Constant Summary collapse
- ATTRIBUTES_TO_REMOVE =
%w[environment account created_at updated_at enabled account_type].freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.get_all_configs(environment) ⇒ Object
18 19 20 21 22 |
# File 'lib/generators/wechat/templates/app/models/wechat_config.rb', line 18 def self.get_all_configs(environment) WechatConfig.where(environment: environment, enabled: true).each_with_object({}) do |config, hash| hash[config.account] = config.build_config_hash end end |
Instance Method Details
#build_config_hash ⇒ Object
24 25 26 27 28 |
# File 'lib/generators/wechat/templates/app/models/wechat_config.rb', line 24 def build_config_hash config_hash = as_json(except: ATTRIBUTES_TO_REMOVE) config_hash[:type] = account_type if account_type.present? config_hash end |