Class: WechatConfig

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



13
14
15
16
17
18
# File 'app/models/wechat_config.rb', line 13

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



20
21
22
# File 'app/models/wechat_config.rb', line 20

def build_config_hash
  self.as_json(except: ATTRIBUTES_TO_REMOVE)
end