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].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get_all_configs(environment) ⇒ Object



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

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

Instance Method Details

#build_config_hashObject



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

def build_config_hash
  as_json(except: ATTRIBUTES_TO_REMOVE)
end