activekit 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d79cd1518b90bb64257a77318f59cfa3f2bfa9bb58a45ead89ddfa5bcb08b001
4
- data.tar.gz: c8891e2351e0940b765a0a5c296403f2885fac4b64db00b822d32707f84b156c
3
+ metadata.gz: cf28e084bf1e87d21b36b3abcce5f3ebc902595a9635396f985c3935467e6b48
4
+ data.tar.gz: ee2abf2cd217e523b35aa980dfa84072dee883dde5a2a782f864453740448321
5
5
  SHA512:
6
- metadata.gz: 83975dd7d4e472532c0b1afa3afcf2aebda640093f6cedb325c9b69adc50f8216e8cc59edaea6f2d923320be8e7409e026c3d36ba48f29469acec41a97bf609b
7
- data.tar.gz: 6bb3596f95f6893e9ce5a342b96ac22ed2d72cf36866900fa75fedb8a6a397020c0d3295160f1ddca8bee1a36921adf3e055d0e65b1b7d6d60caa6dc7975401b
6
+ metadata.gz: f9848ed64694d379141ab41865234ac80f6042452be9a3a34ee2f94db61fa7a9c4e3bd564fb85c6029bd7e86379e773fc5b3945a7676ea4955489cd325a72bd4
7
+ data.tar.gz: 8724f2eb4848df56dd589ad04e241c8a95a47d27b80e2d3c7bc1838f4b02a76e726115c27c03f449699c40ca34c8f50667254b1056408dea42bf02e5aafa5bc0
@@ -0,0 +1,9 @@
1
+ module ActiveKit
2
+ class Attribute < ApplicationRecord
3
+ belongs_to :record, polymorphic: true
4
+
5
+ store :value, accessors: [ :sequence ], coder: JSON
6
+
7
+ validates :value, presence: true, length: { maximum: 1073741823, allow_blank: true }
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreateActiveKitAttributes < ActiveRecord::Migration[6.1]
2
+ def change
3
+ create_table :active_kit_attributes do |t|
4
+ t.references :record, polymorphic: true, index: true
5
+ t.text :value, size: :long
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ require 'active_support/concern'
2
+ require "active_kit/sequence/sequenceable"
3
+
4
+ module ActiveKit
5
+ module Activekitable
6
+ extend ActiveSupport::Concern
7
+ include ActiveKit::Sequence::Sequenceable
8
+
9
+ included do
10
+ end
11
+
12
+ class_methods do
13
+ end
14
+ end
15
+ end
@@ -3,11 +3,13 @@ module ActiveKit
3
3
  isolate_namespace ActiveKit
4
4
  config.eager_load_namespaces << ActiveKit
5
5
 
6
- initializer "active_kit.sequence" do
7
- require "active_kit/sequence/sequenceable"
6
+ initializer "active_kit.activekitable" do
7
+ require "active_kit/activekitable"
8
8
 
9
9
  ActiveSupport.on_load(:active_record) do
10
- include ActiveKit::Sequence::Sequenceable
10
+ include ActiveKit::Activekitable
11
+
12
+ has_one :activekit, as: :record, dependent: :destroy, class_name: "ActiveKit::Attribute"
11
13
  end
12
14
  end
13
15
  end
@@ -24,27 +24,18 @@ module ActiveKit
24
24
 
25
25
  unless self.respond_to?(:sequencer)
26
26
  define_singleton_method :sequencer do
27
- @sequencer ||= ActiveSequence::Sequencer.new(current_class: self)
27
+ @sequencer ||= ActiveKit::Sequence::Sequencer.new(current_class: self)
28
28
  end
29
29
 
30
- has_many :sequence_attributes, as: :record, dependent: :destroy, class_name: "ActiveSequence::Attribute"
31
30
  # scope :order_sequence, -> (options_hash) { includes(:sequence_attributes).where(sequence_attributes: { name: name.to_s }).order("sequence_attributes.value": :asc) }
32
31
  end
33
32
 
34
- set_active_sequence_create_callbacks(attribute_name: name)
35
- set_active_sequence_commit_callbacks(attribute_name: name, positioning_method: positioning_method, updater: options.delete(:updater))
33
+ set_active_sequence_callbacks(attribute_name: name, positioning_method: positioning_method, updater: options.delete(:updater))
36
34
 
37
35
  sequencer.add_attribute(name: name, options: options)
38
36
  end
39
37
 
40
- def set_active_sequence_create_callbacks(attribute_name:)
41
- before_create do
42
- self.sequence_attributes.find_or_initialize_by(name: attribute_name)
43
- logger.info "ActiveSequence - Creating Sequence attribute '#{attribute}' from #{self.class.name}: Done."
44
- end
45
- end
46
-
47
- def set_active_sequence_commit_callbacks(attribute_name:, positioning_method:, updater:)
38
+ def set_active_sequence_callbacks(attribute_name:, positioning_method:, updater:)
48
39
  updater = updater || {}
49
40
 
50
41
  if updater.empty?
@@ -0,0 +1,8 @@
1
+ module ActiveKit
2
+ module Sequence
3
+ extend ActiveSupport::Autoload
4
+
5
+ autoload :Sequencer
6
+ autoload :Wordbook
7
+ end
8
+ end
@@ -1,3 +1,3 @@
1
1
  module ActiveKit
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.3'
3
3
  end
data/lib/active_kit.rb CHANGED
@@ -4,6 +4,5 @@ require "active_kit/engine"
4
4
  module ActiveKit
5
5
  extend ActiveSupport::Autoload
6
6
 
7
- autoload :Sequencer, "active_kit/sequence/sequencer"
8
- autoload :Wordbook, "active_kit/sequence/wordbook"
7
+ autoload :Sequence
9
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activekit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - plainsource
@@ -47,10 +47,14 @@ files:
47
47
  - app/jobs/active_kit/application_job.rb
48
48
  - app/mailers/active_kit/application_mailer.rb
49
49
  - app/models/active_kit/application_record.rb
50
+ - app/models/active_kit/attribute.rb
50
51
  - app/views/layouts/active_kit/application.html.erb
51
52
  - config/routes.rb
53
+ - db/migrate/20231016050208_create_active_kit_attributes.rb
52
54
  - lib/active_kit.rb
55
+ - lib/active_kit/activekitable.rb
53
56
  - lib/active_kit/engine.rb
57
+ - lib/active_kit/sequence.rb
54
58
  - lib/active_kit/sequence/sequenceable.rb
55
59
  - lib/active_kit/sequence/sequencer.rb
56
60
  - lib/active_kit/sequence/wordbook.rb