error_response 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/error_response.rb +11 -4
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9399ce1f1928133803e46493fdd9a83e89b4c91002ec1168173081f5ecc5a9d7
4
- data.tar.gz: 9255d7dc8f8d9274dabd4e4d274d0d99900edbd66723f7335ed5eaf20f97e379
3
+ metadata.gz: fb1fff56885d056e0ff23ba2da10daa85875a60c3c6afb97a840ac601f23f138
4
+ data.tar.gz: 28342938f10616bfba217b042b58156f83c82831f524717a446edeb17ce8d032
5
5
  SHA512:
6
- metadata.gz: a70f5c87344a5fc8561eaa00807b4eb9dd50f5766dba600457991241b52e0490b7fd0f180c9af96d4fa0e27871fa4a4c78a8e5c8c0a9bf12f8c24ffa2489f629
7
- data.tar.gz: dcfa05015e5da084ad0aab70ce9c90af354a54d8cc602f515c622ca68de290c453565537b591968ba9923063606a4bd6731d637c7e8912af19dd3ee7a24eb71e
6
+ metadata.gz: 5d32e77ff063489bce54f894b158b18a53b7d211ee7cf92a8f3aa47b9425f6baafc30b9cfc6238f5d25109bc49f8fe392b3363d6bde1be34607eee9b08bf85db
7
+ data.tar.gz: 0ca3cfd25e3073fadd087587007c00a548b8ea9ad225ba6eace37ecaf326f57048a788c5e869a8013ba86125d3b775cfe1ce2046ad3a6651f0d4fe65af60898c
@@ -4,8 +4,7 @@ class ErrorResponse
4
4
  YAML_PATH = 'lib/error_response.yml'
5
5
 
6
6
  def self.to_api(key, message=nil)
7
- string_hash = YAML.load_file(File.join(GEM_ROOT,YAML_PATH))
8
- err_json = string_hash[key.to_s] || {'error_code' => 500000, 'error_message' => message}
7
+ err_json = yaml_hash[key.to_s] || {'error_code' => 500000, 'error_message' => message}
9
8
 
10
9
  status = err_json['error_code'] / 1000
11
10
  {
@@ -15,7 +14,15 @@ class ErrorResponse
15
14
  end
16
15
 
17
16
  def self.to_hash(key)
18
- string_hash = YAML.load_file(File.join(GEM_ROOT,YAML_PATH))
19
- string_hash[key.to_s]
17
+ yaml_hash[key.to_s]
18
+ end
19
+
20
+ def self.all
21
+ yaml_hash
22
+ end
23
+
24
+ private
25
+ def self.yaml_hash
26
+ yaml ||= YAML.load_file(File.join(GEM_ROOT,YAML_PATH))
20
27
  end
21
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: error_response
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - jameslee