aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/generic_attribute_control
diff options
context:
space:
mode:
authorTeddy Wing2017-12-19 16:35:09 +0100
committerLuc Donnet2017-12-21 15:32:42 +0100
commit4918ffcd7492661f36a763cdf248757993f9bff4 (patch)
tree11589d965fb2b4baf5c0e4db1ff5413946f87c4d /app/models/generic_attribute_control
parentd9f3af834a06a6d4e73c083440926983ac5e2cfa (diff)
downloadchouette-core-4918ffcd7492661f36a763cdf248757993f9bff4.tar.bz2
Remove `hstore_accessor` usage
The places we were using `hstore_accessor` have now been converted to Postgres JSON fields. Thus we no longer need `hstore_accessor` in order to add accessors for the fields. Instead we can use Rails' built-in support for Postgres JSON fields and create accessors for our JSON hash keys with `store_accessor`. We get rid of the data types because `store_accessor` doesn't work like that and JSON already types our values with primitive data types. Finally, add some extra validation tests now that the vaildation for our JSON fields should work. Refs #5316
Diffstat (limited to 'app/models/generic_attribute_control')
-rw-r--r--app/models/generic_attribute_control/min_max.rb2
-rw-r--r--app/models/generic_attribute_control/pattern.rb2
-rw-r--r--app/models/generic_attribute_control/uniqueness.rb2
3 files changed, 3 insertions, 3 deletions
diff --git a/app/models/generic_attribute_control/min_max.rb b/app/models/generic_attribute_control/min_max.rb
index ab6f546a7..1c429b9a4 100644
--- a/app/models/generic_attribute_control/min_max.rb
+++ b/app/models/generic_attribute_control/min_max.rb
@@ -1,6 +1,6 @@
module GenericAttributeControl
class MinMax < ComplianceControl
- hstore_accessor :control_attributes, minimum: :integer, maximum: :integer, target: :string
+ store_accessor :control_attributes, :minimum, :maximum, :target
validates :minimum, numericality: true, allow_nil: true
validates :maximum, numericality: true, allow_nil: true
diff --git a/app/models/generic_attribute_control/pattern.rb b/app/models/generic_attribute_control/pattern.rb
index 3a4a55d5c..7fc008e28 100644
--- a/app/models/generic_attribute_control/pattern.rb
+++ b/app/models/generic_attribute_control/pattern.rb
@@ -1,6 +1,6 @@
module GenericAttributeControl
class Pattern < ComplianceControl
- hstore_accessor :control_attributes, pattern: :string, target: :string
+ store_accessor :control_attributes, :pattern, :target
validates :target, presence: true
validates :pattern, presence: true
diff --git a/app/models/generic_attribute_control/uniqueness.rb b/app/models/generic_attribute_control/uniqueness.rb
index f707c944b..82b5c0892 100644
--- a/app/models/generic_attribute_control/uniqueness.rb
+++ b/app/models/generic_attribute_control/uniqueness.rb
@@ -1,6 +1,6 @@
module GenericAttributeControl
class Uniqueness < ComplianceControl
- hstore_accessor :control_attributes, target: :string
+ store_accessor :control_attributes, :target
validates :target, presence: true