vimo 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/app/models/vimo/expandable.rb +40 -0
- data/app/models/vimo/item.rb +1 -1
- data/db/migrate/20180210104430_create_vimo_items.rb +1 -1
- data/lib/vimo/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 165c7157085ad7675a72fcb99f22444322f0d235635e58103425a43eaab43da1
|
4
|
+
data.tar.gz: e54c776796bebdde6113a7d58e77afab59d5a4779dbed48df470c9b912f83707
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ef13ba029adac1b3b17a3ac17c42df29f4ce1a1bc1bb693e0d73ebbc230ab4a805f4ee8f90092d014e963db06dbe8f9f145df6576430a9e6547ba7c1358f86c
|
7
|
+
data.tar.gz: 8b56cd796a0609b4305a759e93828d1b8fde8eabdf8e8d3b67bc3ed5f5ca0ca022c41d5226ffbfe6e2c0b14e9114b262e41505ad11a79f9a0b19c78606b67f9b
|
data/README.md
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Vimo
|
4
|
+
module Expandable
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
|
9
|
+
def self.vimo_expand(options = {})
|
10
|
+
@@belongs_to_owner = options[:owner]
|
11
|
+
|
12
|
+
self.class_eval do
|
13
|
+
|
14
|
+
has_one :expanded, as: :expandable, class_name: "Vimo::Item"
|
15
|
+
delegate :data, to: :expanded
|
16
|
+
|
17
|
+
def vimo_owner
|
18
|
+
send(@@belongs_to_owner) if @@belongs_to_owner
|
19
|
+
end
|
20
|
+
|
21
|
+
def entities
|
22
|
+
if vimo_owner
|
23
|
+
vimo_owner.vimo_entities
|
24
|
+
else
|
25
|
+
Vimo::Entity
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def expanded
|
30
|
+
super || build_expanded(entity: entities.find_or_create_by!(name: "_expand_#{self.class.table_name}"))
|
31
|
+
end
|
32
|
+
|
33
|
+
def entity_fields
|
34
|
+
@entity_fields ||= expanded.entity.fields
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/app/models/vimo/item.rb
CHANGED
@@ -2,7 +2,7 @@ class CreateVimoItems < ActiveRecord::Migration[5.1]
|
|
2
2
|
def change
|
3
3
|
create_table :vimo_items do |t|
|
4
4
|
t.references :entity, foreign_key: true
|
5
|
-
t.references :
|
5
|
+
t.references :expandable, polymorphic: true, index: true
|
6
6
|
t.text :data
|
7
7
|
|
8
8
|
t.timestamps
|
data/lib/vimo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vimo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jose Galisteo
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- app/mailers/vimo/application_mailer.rb
|
150
150
|
- app/models/vimo/application_record.rb
|
151
151
|
- app/models/vimo/entity.rb
|
152
|
+
- app/models/vimo/expandable.rb
|
152
153
|
- app/models/vimo/field.rb
|
153
154
|
- app/models/vimo/item.rb
|
154
155
|
- app/models/vimo/system_name.rb
|