actionstore 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +3 -0
- data/lib/actionstore/actionstore.rb +40 -0
- data/lib/actionstore/active_record.rb +3 -0
- data/lib/actionstore/channel.rb +27 -0
- data/lib/actionstore/railtie.rb +4 -0
- data/lib/actionstore/version.rb +3 -0
- data/lib/actionstore.rb +6 -0
- data/lib/tasks/actionstore_tasks.rake +4 -0
- metadata +68 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2c675d4099278efecc835c8898f8817c6bdd5cd820f90524455e64cf3dbb6efe
|
4
|
+
data.tar.gz: 3d8dd1b6295f294b4d7caa02fcbbae498d764d540125938b48425c3ca46b35a3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bc67a5d2caa7a31b8c6c66cfe0f15dd3afd7a028acf74f7e268d4953faeebb3937ab7b6516c06b7096b868b4a4859f69305ba20e85b8633e81e49345a16d46ad
|
7
|
+
data.tar.gz: cae2b6a42e66647ba6c3d736b7d6113e665541d599fdfaa0faf64c6399179e0acfe9d3ef3898d9d4512538ebc689e38965adbf31102e231891a8655ba6692d7a
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module Actionstore
|
2
|
+
|
3
|
+
def self.store_id subject
|
4
|
+
if subject.nil?
|
5
|
+
nil
|
6
|
+
elsif subject.is_a? String
|
7
|
+
subject
|
8
|
+
elsif subject.respond_to? :to_store_id
|
9
|
+
subject.to_store_id
|
10
|
+
else
|
11
|
+
ActionView::RecordIdentifier.dom_id subject
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module ClassMethods
|
16
|
+
def has_actionstore
|
17
|
+
include Actionstore::InstanceMethods
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
module InstanceMethods
|
22
|
+
extend ActiveSupport::Concern
|
23
|
+
|
24
|
+
def serialized_changes
|
25
|
+
saved_changes.transform_values(&:last)
|
26
|
+
end
|
27
|
+
|
28
|
+
def push_update changes
|
29
|
+
push_update_into nil, changes
|
30
|
+
end
|
31
|
+
|
32
|
+
def push_update_into store_id, changes = {}
|
33
|
+
Actionstore::Channel.broadcast_to self, store_id: Actionstore.store_id(store_id), action: 'update', changes: changes
|
34
|
+
end
|
35
|
+
|
36
|
+
def push_event event, data = nil
|
37
|
+
Actionstore::Channel.broadcast_to self, action: event, data: data
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Actionstore
|
2
|
+
class Channel < ActionCable::Channel::Base
|
3
|
+
def subscribed
|
4
|
+
@subject = GlobalID::Locator.locate_signed params[:sgid]
|
5
|
+
return reject unless @subject
|
6
|
+
stream_for @subject
|
7
|
+
@subject.subscribed self if @subject.respond_to? :subscribed
|
8
|
+
end
|
9
|
+
|
10
|
+
def push_update changes
|
11
|
+
push_update_into nil, changes
|
12
|
+
end
|
13
|
+
|
14
|
+
def push_update_into store_id, changes
|
15
|
+
store_id = ActionStore.store_id(store_id)
|
16
|
+
transmit({store_id: store_id, action: 'update', changes: changes})
|
17
|
+
end
|
18
|
+
|
19
|
+
def perform_action data
|
20
|
+
@subject.send "perform_#{data['action']}", current_user, *data['args']
|
21
|
+
end
|
22
|
+
|
23
|
+
def unsubscribed
|
24
|
+
@subject.unsubscribed self if @subject.respond_to? :unsubscribed
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/actionstore.rb
ADDED
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: actionstore
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stefan Buhrmester
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-10-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 7.0.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 7.0.4
|
27
|
+
description: Push data into Svelte stores from Rails
|
28
|
+
email:
|
29
|
+
- buhrmi@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- Rakefile
|
35
|
+
- lib/actionstore.rb
|
36
|
+
- lib/actionstore/actionstore.rb
|
37
|
+
- lib/actionstore/active_record.rb
|
38
|
+
- lib/actionstore/channel.rb
|
39
|
+
- lib/actionstore/railtie.rb
|
40
|
+
- lib/actionstore/version.rb
|
41
|
+
- lib/tasks/actionstore_tasks.rake
|
42
|
+
homepage: https://github.com/buhrmi/actionstore
|
43
|
+
licenses:
|
44
|
+
- MIT
|
45
|
+
metadata:
|
46
|
+
homepage_uri: https://github.com/buhrmi/actionstore
|
47
|
+
source_code_uri: https://github.com/buhrmi/actionstore
|
48
|
+
changelog_uri: https://github.com/buhrmi/actionstore
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubygems_version: 3.3.7
|
65
|
+
signing_key:
|
66
|
+
specification_version: 4
|
67
|
+
summary: Push data into Svelte stores from Rails
|
68
|
+
test_files: []
|