active_fields 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +0 -1
- data/.rubocop.yml +3 -15
- data/CHANGELOG.md +7 -0
- data/Rakefile +7 -0
- data/app/models/active_fields/application_record.rb +7 -0
- data/app/models/active_fields/field/base.rb +17 -0
- data/{lib/active_fields/models → app/models/active_fields}/field/boolean.rb +4 -6
- data/{lib/active_fields/models → app/models/active_fields}/field/date.rb +6 -8
- data/{lib/active_fields/models → app/models/active_fields}/field/date_array.rb +6 -8
- data/{lib/active_fields/models → app/models/active_fields}/field/decimal.rb +6 -8
- data/{lib/active_fields/models → app/models/active_fields}/field/decimal_array.rb +6 -8
- data/{lib/active_fields/models → app/models/active_fields}/field/enum.rb +6 -8
- data/{lib/active_fields/models → app/models/active_fields}/field/enum_array.rb +6 -8
- data/{lib/active_fields/models → app/models/active_fields}/field/integer.rb +6 -8
- data/{lib/active_fields/models → app/models/active_fields}/field/integer_array.rb +4 -6
- data/{lib/active_fields/models → app/models/active_fields}/field/text.rb +6 -8
- data/{lib/active_fields/models → app/models/active_fields}/field/text_array.rb +4 -6
- data/app/models/active_fields/value.rb +15 -0
- data/{lib/active_fields/models/concerns/customizable.rb → app/models/concerns/active_fields/customizable_concern.rb} +6 -4
- data/{lib/active_fields/models/concerns → app/models/concerns/active_fields}/field_concern.rb +14 -3
- data/{lib/active_fields/models/concerns → app/models/concerns/active_fields}/value_concern.rb +7 -2
- data/config/routes.rb +4 -0
- data/{lib/generators/active_fields/install/templates/create_active_fields_tables.rb.tt → db/migrate/20240229230000_create_active_fields_tables.rb} +6 -4
- data/lib/active_fields/casters/boolean_caster.rb +0 -2
- data/lib/active_fields/casters/date_array_caster.rb +0 -2
- data/lib/active_fields/casters/date_caster.rb +0 -2
- data/lib/active_fields/casters/decimal_array_caster.rb +0 -2
- data/lib/active_fields/casters/decimal_caster.rb +0 -2
- data/lib/active_fields/casters/enum_array_caster.rb +0 -2
- data/lib/active_fields/casters/enum_caster.rb +0 -2
- data/lib/active_fields/casters/integer_array_caster.rb +0 -2
- data/lib/active_fields/casters/integer_caster.rb +1 -3
- data/lib/active_fields/casters/text_array_caster.rb +0 -2
- data/lib/active_fields/casters/text_caster.rb +0 -2
- data/lib/active_fields/config.rb +50 -0
- data/lib/active_fields/customizable_config.rb +24 -0
- data/lib/active_fields/engine.rb +13 -0
- data/lib/active_fields/has_active_fields.rb +19 -0
- data/lib/active_fields/validators/boolean_validator.rb +0 -2
- data/lib/active_fields/validators/date_array_validator.rb +0 -2
- data/lib/active_fields/validators/date_validator.rb +0 -2
- data/lib/active_fields/validators/decimal_array_validator.rb +0 -2
- data/lib/active_fields/validators/decimal_validator.rb +0 -2
- data/lib/active_fields/validators/enum_array_validator.rb +0 -2
- data/lib/active_fields/validators/enum_validator.rb +0 -2
- data/lib/active_fields/validators/integer_array_validator.rb +0 -2
- data/lib/active_fields/validators/integer_validator.rb +0 -2
- data/lib/active_fields/validators/text_array_validator.rb +0 -2
- data/lib/active_fields/validators/text_validator.rb +0 -2
- data/lib/active_fields/version.rb +1 -1
- data/lib/active_fields.rb +43 -7
- data/lib/tasks/active_fields_tasks.rake +6 -0
- metadata +52 -34
- data/lib/active_fields/models/concerns/concern.rb +0 -16
- data/lib/active_fields/models/field.rb +0 -27
- data/lib/active_fields/models/value.rb +0 -30
- data/lib/generators/active_fields/install/USAGE +0 -5
- data/lib/generators/active_fields/install/install_generator.rb +0 -33
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateActiveFieldsTables < ActiveRecord::Migration[6.0]
|
2
4
|
def change
|
3
5
|
create_table :active_fields do |t|
|
4
6
|
t.string :name, null: false
|
@@ -9,7 +11,7 @@ class CreateActiveFieldsTables < ActiveRecord::Migration<%= migration_version %>
|
|
9
11
|
|
10
12
|
t.timestamps
|
11
13
|
|
12
|
-
t.index [
|
14
|
+
t.index %i[name customizable_type], unique: true
|
13
15
|
t.index :customizable_type
|
14
16
|
end
|
15
17
|
|
@@ -17,12 +19,12 @@ class CreateActiveFieldsTables < ActiveRecord::Migration<%= migration_version %>
|
|
17
19
|
t.references :customizable, polymorphic: true, null: false, index: false
|
18
20
|
t.references :active_field,
|
19
21
|
null: false,
|
20
|
-
foreign_key: { to_table: :active_fields, name:
|
22
|
+
foreign_key: { to_table: :active_fields, name: "active_fields_values_active_field_id_fk" }
|
21
23
|
t.jsonb :value
|
22
24
|
|
23
25
|
t.timestamps
|
24
26
|
|
25
|
-
t.index [
|
27
|
+
t.index %i[customizable_type customizable_id active_field_id],
|
26
28
|
unique: true,
|
27
29
|
name: "index_active_fields_values_on_customizable_and_field"
|
28
30
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "base_caster"
|
4
|
-
|
5
3
|
module ActiveFields
|
6
4
|
module Casters
|
7
5
|
class IntegerCaster < DecimalCaster
|
@@ -16,7 +14,7 @@ module ActiveFields
|
|
16
14
|
private
|
17
15
|
|
18
16
|
def cast(value)
|
19
|
-
super
|
17
|
+
super&.to_i
|
20
18
|
end
|
21
19
|
end
|
22
20
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveFields
|
4
|
+
class Config
|
5
|
+
DEFAULT_FIELD_BASE_CLASS_NAME = "ActiveFields::Field::Base"
|
6
|
+
DEFAULT_VALUE_CLASS_NAME = "ActiveFields::Value"
|
7
|
+
|
8
|
+
include Singleton
|
9
|
+
|
10
|
+
attr_accessor :field_base_class_name, :value_class_name, :fields
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@field_base_class_name = DEFAULT_FIELD_BASE_CLASS_NAME
|
14
|
+
@value_class_name = DEFAULT_VALUE_CLASS_NAME
|
15
|
+
@fields = {
|
16
|
+
boolean: "ActiveFields::Field::Boolean",
|
17
|
+
date: "ActiveFields::Field::Date",
|
18
|
+
date_array: "ActiveFields::Field::DateArray",
|
19
|
+
decimal: "ActiveFields::Field::Decimal",
|
20
|
+
decimal_array: "ActiveFields::Field::DecimalArray",
|
21
|
+
enum: "ActiveFields::Field::Enum",
|
22
|
+
enum_array: "ActiveFields::Field::EnumArray",
|
23
|
+
integer: "ActiveFields::Field::Integer",
|
24
|
+
integer_array: "ActiveFields::Field::IntegerArray",
|
25
|
+
text: "ActiveFields::Field::Text",
|
26
|
+
text_array: "ActiveFields::Field::TextArray",
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def field_base_class
|
31
|
+
@field_base_class ||= field_base_class_name.constantize
|
32
|
+
end
|
33
|
+
|
34
|
+
def value_class
|
35
|
+
@value_class ||= value_class_name.constantize
|
36
|
+
end
|
37
|
+
|
38
|
+
def field_base_class_changed?
|
39
|
+
field_base_class_name != DEFAULT_FIELD_BASE_CLASS_NAME
|
40
|
+
end
|
41
|
+
|
42
|
+
def value_class_changed?
|
43
|
+
value_class_name != DEFAULT_VALUE_CLASS_NAME
|
44
|
+
end
|
45
|
+
|
46
|
+
def register_field(type_name, class_name)
|
47
|
+
@fields[type_name.to_sym] = class_name
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveFields
|
4
|
+
class CustomizableConfig
|
5
|
+
attr_reader :customizable_model, :types
|
6
|
+
|
7
|
+
def initialize(customizable_model)
|
8
|
+
@customizable_model = customizable_model
|
9
|
+
end
|
10
|
+
|
11
|
+
def types=(value)
|
12
|
+
invalid_types = value - ActiveFields.config.fields.keys
|
13
|
+
if invalid_types.any?
|
14
|
+
raise ArgumentError, "undefined ActiveFields types provided for #{customizable_model}: #{invalid_types}"
|
15
|
+
end
|
16
|
+
|
17
|
+
@types = value
|
18
|
+
end
|
19
|
+
|
20
|
+
def types_class_names
|
21
|
+
ActiveFields.config.fields.values_at(*types)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveFields
|
4
|
+
class Engine < ::Rails::Engine
|
5
|
+
isolate_namespace ActiveFields
|
6
|
+
|
7
|
+
initializer "active_fields.active_record" do
|
8
|
+
ActiveSupport.on_load(:active_record) do
|
9
|
+
include HasActiveFields
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveFields
|
4
|
+
# Mix-in that allows ActiveRecord models to enable active fields
|
5
|
+
module HasActiveFields
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
class_methods do
|
9
|
+
attr_reader :active_fields_config
|
10
|
+
|
11
|
+
def has_active_fields(types: ActiveFields.config.fields.keys)
|
12
|
+
include CustomizableConcern
|
13
|
+
|
14
|
+
@active_fields_config = CustomizableConfig.new(self)
|
15
|
+
@active_fields_config.types = types
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/active_fields.rb
CHANGED
@@ -1,13 +1,49 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "active_support"
|
4
|
-
require "active_record"
|
5
|
-
|
6
3
|
require_relative "active_fields/version"
|
7
|
-
|
8
|
-
Dir["#{__dir__}/active_fields/validators/**/*.rb"].each { |f| require_relative f }
|
9
|
-
Dir["#{__dir__}/active_fields/models/**/*.rb"].each { |f| require_relative f }
|
4
|
+
require_relative "active_fields/engine"
|
10
5
|
|
11
6
|
module ActiveFields
|
12
|
-
|
7
|
+
autoload :Config, "active_fields/config"
|
8
|
+
autoload :CustomizableConfig, "active_fields/customizable_config"
|
9
|
+
autoload :HasActiveFields, "active_fields/has_active_fields"
|
10
|
+
|
11
|
+
module Casters
|
12
|
+
autoload :BaseCaster, "active_fields/casters/base_caster"
|
13
|
+
autoload :BooleanCaster, "active_fields/casters/boolean_caster"
|
14
|
+
autoload :DateCaster, "active_fields/casters/date_caster"
|
15
|
+
autoload :DateArrayCaster, "active_fields/casters/date_array_caster"
|
16
|
+
autoload :DecimalCaster, "active_fields/casters/decimal_caster"
|
17
|
+
autoload :DecimalArrayCaster, "active_fields/casters/decimal_array_caster"
|
18
|
+
autoload :EnumCaster, "active_fields/casters/enum_caster"
|
19
|
+
autoload :EnumArrayCaster, "active_fields/casters/enum_array_caster"
|
20
|
+
autoload :IntegerCaster, "active_fields/casters/integer_caster"
|
21
|
+
autoload :IntegerArrayCaster, "active_fields/casters/integer_array_caster"
|
22
|
+
autoload :TextCaster, "active_fields/casters/text_caster"
|
23
|
+
autoload :TextArrayCaster, "active_fields/casters/text_array_caster"
|
24
|
+
end
|
25
|
+
|
26
|
+
module Validators
|
27
|
+
autoload :BaseValidator, "active_fields/validators/base_validator"
|
28
|
+
autoload :BooleanValidator, "active_fields/validators/boolean_validator"
|
29
|
+
autoload :DateValidator, "active_fields/validators/date_validator"
|
30
|
+
autoload :DateArrayValidator, "active_fields/validators/date_array_validator"
|
31
|
+
autoload :DecimalValidator, "active_fields/validators/decimal_validator"
|
32
|
+
autoload :DecimalArrayValidator, "active_fields/validators/decimal_array_validator"
|
33
|
+
autoload :EnumValidator, "active_fields/validators/enum_validator"
|
34
|
+
autoload :EnumArrayValidator, "active_fields/validators/enum_array_validator"
|
35
|
+
autoload :IntegerValidator, "active_fields/validators/integer_validator"
|
36
|
+
autoload :IntegerArrayValidator, "active_fields/validators/integer_array_validator"
|
37
|
+
autoload :TextValidator, "active_fields/validators/text_validator"
|
38
|
+
autoload :TextArrayValidator, "active_fields/validators/text_array_validator"
|
39
|
+
end
|
40
|
+
|
41
|
+
class << self
|
42
|
+
def config
|
43
|
+
yield Config.instance if block_given?
|
44
|
+
Config.instance
|
45
|
+
end
|
46
|
+
|
47
|
+
alias_method :configure, :config
|
48
|
+
end
|
13
49
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill Usanov
|
@@ -9,10 +9,10 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-06-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: rails
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
@@ -26,21 +26,21 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '6.0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: factory_bot
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
35
|
-
type: :
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: pg
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: puma
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - ">="
|
@@ -68,7 +68,7 @@ dependencies:
|
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
71
|
+
name: rake
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - ">="
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
85
|
+
name: rspec-rails
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - ">="
|
@@ -96,7 +96,7 @@ dependencies:
|
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
|
-
name:
|
99
|
+
name: rubocop
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
102
|
- - ">="
|
@@ -110,7 +110,7 @@ dependencies:
|
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
|
-
name: rubocop
|
113
|
+
name: rubocop-factory_bot
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
116
|
- - ">="
|
@@ -179,6 +179,20 @@ dependencies:
|
|
179
179
|
- - ">="
|
180
180
|
- !ruby/object:Gem::Version
|
181
181
|
version: '0'
|
182
|
+
- !ruby/object:Gem::Dependency
|
183
|
+
name: rubocop-rspec_rails
|
184
|
+
requirement: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - ">="
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '0'
|
189
|
+
type: :development
|
190
|
+
prerelease: false
|
191
|
+
version_requirements: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - ">="
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '0'
|
182
196
|
- !ruby/object:Gem::Dependency
|
183
197
|
name: rubocop-shopify
|
184
198
|
requirement: !ruby/object:Gem::Requirement
|
@@ -206,6 +220,25 @@ files:
|
|
206
220
|
- LICENSE
|
207
221
|
- README.md
|
208
222
|
- Rakefile
|
223
|
+
- app/models/active_fields/application_record.rb
|
224
|
+
- app/models/active_fields/field/base.rb
|
225
|
+
- app/models/active_fields/field/boolean.rb
|
226
|
+
- app/models/active_fields/field/date.rb
|
227
|
+
- app/models/active_fields/field/date_array.rb
|
228
|
+
- app/models/active_fields/field/decimal.rb
|
229
|
+
- app/models/active_fields/field/decimal_array.rb
|
230
|
+
- app/models/active_fields/field/enum.rb
|
231
|
+
- app/models/active_fields/field/enum_array.rb
|
232
|
+
- app/models/active_fields/field/integer.rb
|
233
|
+
- app/models/active_fields/field/integer_array.rb
|
234
|
+
- app/models/active_fields/field/text.rb
|
235
|
+
- app/models/active_fields/field/text_array.rb
|
236
|
+
- app/models/active_fields/value.rb
|
237
|
+
- app/models/concerns/active_fields/customizable_concern.rb
|
238
|
+
- app/models/concerns/active_fields/field_concern.rb
|
239
|
+
- app/models/concerns/active_fields/value_concern.rb
|
240
|
+
- config/routes.rb
|
241
|
+
- db/migrate/20240229230000_create_active_fields_tables.rb
|
209
242
|
- lib/active_fields.rb
|
210
243
|
- lib/active_fields/casters/base_caster.rb
|
211
244
|
- lib/active_fields/casters/boolean_caster.rb
|
@@ -219,23 +252,10 @@ files:
|
|
219
252
|
- lib/active_fields/casters/integer_caster.rb
|
220
253
|
- lib/active_fields/casters/text_array_caster.rb
|
221
254
|
- lib/active_fields/casters/text_caster.rb
|
222
|
-
- lib/active_fields/
|
223
|
-
- lib/active_fields/
|
224
|
-
- lib/active_fields/
|
225
|
-
- lib/active_fields/
|
226
|
-
- lib/active_fields/models/field.rb
|
227
|
-
- lib/active_fields/models/field/boolean.rb
|
228
|
-
- lib/active_fields/models/field/date.rb
|
229
|
-
- lib/active_fields/models/field/date_array.rb
|
230
|
-
- lib/active_fields/models/field/decimal.rb
|
231
|
-
- lib/active_fields/models/field/decimal_array.rb
|
232
|
-
- lib/active_fields/models/field/enum.rb
|
233
|
-
- lib/active_fields/models/field/enum_array.rb
|
234
|
-
- lib/active_fields/models/field/integer.rb
|
235
|
-
- lib/active_fields/models/field/integer_array.rb
|
236
|
-
- lib/active_fields/models/field/text.rb
|
237
|
-
- lib/active_fields/models/field/text_array.rb
|
238
|
-
- lib/active_fields/models/value.rb
|
255
|
+
- lib/active_fields/config.rb
|
256
|
+
- lib/active_fields/customizable_config.rb
|
257
|
+
- lib/active_fields/engine.rb
|
258
|
+
- lib/active_fields/has_active_fields.rb
|
239
259
|
- lib/active_fields/validators/base_validator.rb
|
240
260
|
- lib/active_fields/validators/boolean_validator.rb
|
241
261
|
- lib/active_fields/validators/date_array_validator.rb
|
@@ -249,9 +269,7 @@ files:
|
|
249
269
|
- lib/active_fields/validators/text_array_validator.rb
|
250
270
|
- lib/active_fields/validators/text_validator.rb
|
251
271
|
- lib/active_fields/version.rb
|
252
|
-
- lib/
|
253
|
-
- lib/generators/active_fields/install/install_generator.rb
|
254
|
-
- lib/generators/active_fields/install/templates/create_active_fields_tables.rb.tt
|
272
|
+
- lib/tasks/active_fields_tasks.rake
|
255
273
|
- sig/active_fields.rbs
|
256
274
|
homepage: https://github.com/lassoid/active_fields
|
257
275
|
licenses:
|
@@ -275,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
275
293
|
- !ruby/object:Gem::Version
|
276
294
|
version: '0'
|
277
295
|
requirements: []
|
278
|
-
rubygems_version: 3.5.
|
296
|
+
rubygems_version: 3.5.11
|
279
297
|
signing_key:
|
280
298
|
specification_version: 4
|
281
299
|
summary: Add custom fields to ActiveRecord models at runtime.
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Mix-in that provides ActiveRecord models with active fields functionality
|
4
|
-
module ActiveFields
|
5
|
-
module Concern
|
6
|
-
extend ActiveSupport::Concern
|
7
|
-
|
8
|
-
class_methods do
|
9
|
-
def has_active_fields(options = {})
|
10
|
-
include ActiveFields::Customizable
|
11
|
-
|
12
|
-
@__active_fields_options__ = options.dup
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# == Schema Information
|
4
|
-
#
|
5
|
-
# Table name: active_fields
|
6
|
-
#
|
7
|
-
# id :bigint not null, primary key
|
8
|
-
# customizable_type :string not null
|
9
|
-
# default_value :jsonb
|
10
|
-
# name :string not null
|
11
|
-
# options :jsonb default({}), not null
|
12
|
-
# type :string not null
|
13
|
-
# created_at :datetime not null
|
14
|
-
# updated_at :datetime not null
|
15
|
-
#
|
16
|
-
# Indexes
|
17
|
-
#
|
18
|
-
# index_active_fields_on_customizable_type (customizable_type)
|
19
|
-
# index_active_fields_on_name_and_customizable_type (name,customizable_type) UNIQUE
|
20
|
-
#
|
21
|
-
module ActiveFields
|
22
|
-
class Field < ::ActiveRecord::Base
|
23
|
-
self.table_name = "active_fields"
|
24
|
-
|
25
|
-
include ActiveFields::FieldConcern
|
26
|
-
end
|
27
|
-
end
|