create_custom_attributes 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc552dc1d4611f73fe12579a4ce65aea76a4a3bc
|
4
|
+
data.tar.gz: 8bbbdc05b0261609125ce0cc6b25f1efcf2b90e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 694b6a66cae8731de68d98833ed5d40d176d2d0a94824e53cf95b0c1453e2d776eaa254d6f5ac8827aa9500100e0f145848b8b6f593a923779c9b0b6a597bb72
|
7
|
+
data.tar.gz: 4d37e57058d2ae9e5f2f8f3587203b3acc32019f879274d0d485252e9aa7321ef18950ccda7485681f2c5bcdb0c99b0e36dc8c59e4b293489215cdce5047eff1
|
data/lib/custom_attributes.rb
CHANGED
@@ -26,9 +26,10 @@ require 'custom_attributes/concerns/searchable'
|
|
26
26
|
module CustomAttributes
|
27
27
|
# Gem configuration credits to: https://stackoverflow.com/questions/6233124/where-to-place-access-config-file-in-gem#10112179
|
28
28
|
@config = {
|
29
|
-
search_user: 'elastic',
|
30
|
-
search_pass: 'changeme',
|
31
|
-
search_host: 'localhost:9200'
|
29
|
+
search_user: ENV["ELASTICSEARCH_USER"] || 'elastic',
|
30
|
+
search_pass: ENV["ELASTICSEARCH_PASSWORD"] || 'changeme',
|
31
|
+
search_host: ENV["ELASTICSEARCH_HOST"] || 'localhost:9200',
|
32
|
+
search_index_prefix: ENV["ELASTICSEARCH_INDEX_PREFIX"] || 'es'
|
32
33
|
}
|
33
34
|
|
34
35
|
@valid_config_keys = @config.keys
|
@@ -40,19 +41,6 @@ module CustomAttributes
|
|
40
41
|
after_configuration
|
41
42
|
end
|
42
43
|
|
43
|
-
# Configure through yaml file
|
44
|
-
def self.configure_with(path_to_yaml_file)
|
45
|
-
begin
|
46
|
-
config = YAML.safe_load(IO.read(path_to_yaml_file))
|
47
|
-
rescue Errno::ENOENT
|
48
|
-
log(:warning, "YAML configuration file couldn't be found. Using defaults."); return
|
49
|
-
rescue Psych::SyntaxError
|
50
|
-
log(:warning, 'YAML configuration file contains invalid syntax. Using defaults.'); return
|
51
|
-
end
|
52
|
-
|
53
|
-
configure(config)
|
54
|
-
end
|
55
|
-
|
56
44
|
def self.config
|
57
45
|
@config
|
58
46
|
end
|
@@ -8,7 +8,7 @@ module CustomAttributes
|
|
8
8
|
included do
|
9
9
|
include Elasticsearch::Model
|
10
10
|
|
11
|
-
index_name "#{name.downcase.pluralize}-#{Rails.env}"
|
11
|
+
index_name "#{CustomAttributes.config[:search_index_prefix]}-#{name.downcase.pluralize}-#{Rails.env}"
|
12
12
|
|
13
13
|
# For ActiveRecord-based models, use the after_commit callback to
|
14
14
|
# protect your data against inconsistencies caused by transaction rollbacks
|
@@ -17,6 +17,14 @@ module CustomAttributes
|
|
17
17
|
[[::I18n.t(:general_text_Yes), '1'], [::I18n.t(:general_text_No), '0']]
|
18
18
|
end
|
19
19
|
|
20
|
+
def validate_single_value(_custom_field, value, _customizable = nil)
|
21
|
+
if value == '0' || value == '1'
|
22
|
+
[]
|
23
|
+
else
|
24
|
+
[::I18n.t('activerecord.errors.messages.not_a_boolean')]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
20
28
|
# Boolean supports either checkbox, radiobutton or select field as edit tag
|
21
29
|
def edit_tag(view, tag_id, tag_name, custom_value, options = {})
|
22
30
|
case custom_value.custom_field.edit_tag_style
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: create_custom_attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Grützmacher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|