Class: WechatConfig

Inherits:
ActiveRecord::Base
  • Object
show all
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)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get_all_configs(environment) ⇒ Object



15
16
17
18
19
20
# File 'lib/generators/wechat/templates/app/models/wechat_config.rb', line 15

def self.get_all_configs(environment)
  WechatConfig.where(environment: environment, enabled: true).inject({}) do |hash, config|
    hash[config.] = config.build_config_hash
    hash
  end
end

Instance Method Details

#build_config_hashObject



22
23
24
# File 'lib/generators/wechat/templates/app/models/wechat_config.rb', line 22

def build_config_hash
  self.as_json(except: ATTRIBUTES_TO_REMOVE)
end