Skip to content

Commit 301d5b8

Browse files
Rename validations (#199)
## Changes Rename Flex::Validations to Strata::Validations - Additionally, did some small cleanup with smaller moves + linting
1 parent 489f5db commit 301d5b8

13 files changed

Lines changed: 45 additions & 51 deletions

File tree

app/controllers/concerns/.keep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Flex
1+
module Strata
22
class ApplicationJob < ActiveJob::Base
33
end
44
end

app/lib/strata/attributes/basic_value_object_attribute.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module Strata
22
module Attributes
3-
# Internal module used by other Flex attribute modules to implement attributes
3+
# Internal module used by other Strata attribute modules to implement attributes
44
# whose type is a subclass of Strata::ValueObject. This module is not intended to be
5-
# used directly by clients of Flex.
5+
# used directly by clients of Strata.
66
#
77
# The module provides functionality to create attributes that represent complex values
88
# as value objects, with nested attributes that are automatically mapped to and from
@@ -13,10 +13,10 @@ module Attributes
1313
# - A setter method that accepts either a value object or a hash of values
1414
# - Automatic validation handling for the nested structure
1515
#
16-
# This module is used internally to implement higher-level attribute modules in Flex.
16+
# This module is used internally to implement higher-level attribute modules in Strata.
1717
module BasicValueObjectAttribute
1818
extend ActiveSupport::Concern
19-
include Flex::Validations
19+
include Strata::Validations
2020

2121
class_methods do
2222
# Defines an attribute associated with a subclass of
@@ -56,7 +56,7 @@ def basic_value_object_attribute(name, value_class, nested_attribute_types, opti
5656
end
5757
end
5858

59-
flex_validates_nested(name)
59+
strata_validates_nested(name)
6060
end
6161
end
6262
end

app/lib/strata/attributes/range_attribute.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module Attributes
2020
#
2121
module RangeAttribute
2222
extend ActiveSupport::Concern
23-
include Flex::Validations
23+
include Strata::Validations
2424

2525
def self.attribute_type
2626
:multi_column_value_object
@@ -53,7 +53,7 @@ def range_attribute(name, value_type, options = {})
5353
end
5454
end
5555

56-
flex_validates_nested(name)
56+
strata_validates_nested(name)
5757
end
5858
end
5959
end

app/lib/strata/attributes/us_date_attribute.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Attributes
44
# It allows dates to be stored in a format that is consistent with US conventions
55
module USDateAttribute
66
extend ActiveSupport::Concern
7-
include Flex::Validations
7+
include Strata::Validations
88

99
def self.attribute_type
1010
:single_column_value_object
@@ -28,7 +28,7 @@ def type
2828
class_methods do
2929
def us_date_attribute(name, options)
3030
attribute name, USDateType.new
31-
flex_validates_type_casted_attribute(name, :invalid_date)
31+
strata_validates_type_casted_attribute(name, :invalid_date)
3232
end
3333
end
3434
end

app/lib/strata/attributes/year_month_attribute.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module Attributes
1919
#
2020
module YearMonthAttribute
2121
extend ActiveSupport::Concern
22-
include Flex::Validations
22+
include Strata::Validations
2323

2424
def self.attribute_type
2525
:single_column_value_object
@@ -70,8 +70,8 @@ def deserialize(value)
7070
# @return [void]
7171
def year_month_attribute(name, options = {})
7272
attribute name, YearMonthType.new
73-
flex_validates_nested(name)
74-
flex_validates_type_casted_attribute(name, :invalid_year_month)
73+
strata_validates_nested(name)
74+
strata_validates_type_casted_attribute(name, :invalid_year_month)
7575
end
7676
end
7777
end

app/lib/strata/attributes/year_quarter_attribute.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module Attributes
1919
#
2020
module YearQuarterAttribute
2121
extend ActiveSupport::Concern
22-
include Flex::Validations
22+
include Strata::Validations
2323

2424
def self.attribute_type
2525
:single_column_value_object
@@ -70,8 +70,8 @@ def deserialize(value)
7070
# @return [void]
7171
def year_quarter_attribute(name, options = {})
7272
attribute name, YearQuarterType.new
73-
flex_validates_nested(name)
74-
flex_validates_type_casted_attribute(name, :invalid_year_quarter)
73+
strata_validates_nested(name)
74+
strata_validates_type_casted_attribute(name, :invalid_year_quarter)
7575
end
7676
end
7777
end
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
module Flex
1+
module Strata
22
# Validations is a module that provides nested validation support for value objects.
33
# It extends ActiveModel::Validations to handle validation of nested attributes in a
44
# consistent way, propagating errors from nested objects to the parent model with
55
# appropriate attribute name prefixing.
66
#
77
# This module should be included in models that need to validate nested value objects.
8-
# It provides the flex_validates_nested class method for defining these validations.
8+
# It provides the strata_validates_nested class method for defining these validations.
99
# It is automatically included in the Strata::Attributes module.
1010
#
1111
# @example Including Validations in a model and validating a nested date range
1212
# class MyModel < ApplicationRecord
13-
# include Flex::Validations
13+
# include Strata::Validations
1414
#
15-
# flex_validates_nested :period
15+
# strata_validates_nested :period
1616
# end
1717
#
1818
module Validations
1919
extend ActiveSupport::Concern
2020
include ActiveModel::Validations
2121

2222
class_methods do
23-
def flex_validates_nested(name)
23+
def strata_validates_nested(name)
2424
validate :"validate_nested_#{name}"
2525

2626
# Adds a validator for an attribute that represents a value object.
@@ -49,7 +49,7 @@ def flex_validates_nested(name)
4949
end
5050
end
5151

52-
def flex_validates_type_casted_attribute(name, error_type)
52+
def strata_validates_type_casted_attribute(name, error_type)
5353
validate :"validate_type_casted_attribute_#{name}"
5454

5555
define_method "validate_type_casted_attribute_#{name}" do
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
module Flex
2-
# ApplicationMailer is the base class for all mailers in the Flex SDK.
1+
module Strata
2+
# ApplicationMailer is the base class for all mailers in the Strata SDK.
33
# It provides default settings and layouts for email templates.
44
#
55
# This class inherits from ActionMailer::Base and sets default sender

app/models/strata/value_object.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ValueObject
2121
include ActiveModel::Validations
2222
include ActiveModel::Serializers::JSON
2323
include Strata::Attributes
24-
include Flex::Validations
24+
include Strata::Validations
2525

2626
def ==(other)
2727
return false if self.class != other.class

0 commit comments

Comments
 (0)