logic_pro 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/lib/logic_pro/models_types.rb +24 -0
- data/lib/logic_pro/primitive_types.rb +13 -0
- data/lib/logic_pro/types.rb +1 -9
- data/lib/logic_pro/version.rb +1 -1
- data/lib/logic_pro.rb +2 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b89f8778ba7166bf27fb7d4f24aee4295e819836713b75bccbd8eba0acb86b8
|
4
|
+
data.tar.gz: ddbea924703c05ecf83ff7dbde606c5d40c24dfbd7aff8f5ac97ad5ab4fbf5ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 387fc5e33d7c231ea871df4f74c3fba3115ab0315deb790853728c089f17ad57e6170a77e386ab69b6164f3ce977d3c7a5cfc3dec70a80aa20bb942474bee162
|
7
|
+
data.tar.gz: 19aa8bc09775172d8d3448f4286cff1b01e67241c1632ef0ad24a1457d2cf8f8d5f48e17d813a7c1cbf862100e8cdd65269574e6f099ef36d832f17bff220fe6
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module LogicPro
|
2
|
+
module ModelsTypes
|
3
|
+
def self.add(base, classes)
|
4
|
+
classes.each do |active_record_class_name|
|
5
|
+
active_record_class = active_record_class_name.constantize
|
6
|
+
type_class_name = active_record_class.to_s.gsub('Ratesmgr::', '').gsub('::', '_')
|
7
|
+
|
8
|
+
base.const_set(type_class_name, base::Instance(active_record_class).meta(class_name: active_record_class.name).optional)
|
9
|
+
|
10
|
+
collection_constructor = base::Constructor(active_record_class.none.class) do |collection|
|
11
|
+
if collection.respond_to?(:model) && collection.model == active_record_class
|
12
|
+
collection
|
13
|
+
else
|
14
|
+
raise "Invalid collection type #{collection.class} for #{active_record_class.name}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
base.const_set("#{type_class_name}Collection", collection_constructor.meta(class_name: active_record_class.none.class))
|
19
|
+
end
|
20
|
+
|
21
|
+
parent
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module LogicPro
|
2
|
+
module PrimitiveTypes
|
3
|
+
include Dry.Types()
|
4
|
+
|
5
|
+
Boolean = Bool.constructor { |value| ActiveRecord::Type::Boolean.new.serialize(value) }
|
6
|
+
String = Constructor(::String, &:to_s)
|
7
|
+
Symbol = Constructor(::String, &:to_sym)
|
8
|
+
Hash = Constructor(::Hash, &:to_h)
|
9
|
+
Float = Constructor(::Float, &:to_f)
|
10
|
+
Integer = Constructor(::Integer, &:to_i)
|
11
|
+
DateTime = Constructor(::DateTime) { |value| ::DateTime.parse(value.to_s) if value.present? }
|
12
|
+
end
|
13
|
+
end
|
data/lib/logic_pro/types.rb
CHANGED
@@ -1,13 +1,5 @@
|
|
1
1
|
module LogicPro
|
2
2
|
module Types
|
3
|
-
include
|
4
|
-
|
5
|
-
Boolean = Bool.constructor { |value| ActiveRecord::Type::Boolean.new.serialize(value) }
|
6
|
-
String = Constructor(::String, &:to_s)
|
7
|
-
Symbol = Constructor(::String, &:to_sym)
|
8
|
-
Hash = Constructor(::Hash, &:to_h)
|
9
|
-
Float = Constructor(::Float, &:to_f)
|
10
|
-
Integer = Constructor(::Integer, &:to_i)
|
11
|
-
DateTime = Constructor(::DateTime) { |value| ::DateTime.parse(value.to_s) if value.present? }
|
3
|
+
include LogicPro::PrimitiveTypes
|
12
4
|
end
|
13
5
|
end
|
data/lib/logic_pro/version.rb
CHANGED
data/lib/logic_pro.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logic_pro
|
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
|
- bezrukavyi
|
@@ -74,6 +74,8 @@ files:
|
|
74
74
|
- lib/logic_pro/form.rb
|
75
75
|
- lib/logic_pro/interactor.rb
|
76
76
|
- lib/logic_pro/interactor_form.rb
|
77
|
+
- lib/logic_pro/models_types.rb
|
78
|
+
- lib/logic_pro/primitive_types.rb
|
77
79
|
- lib/logic_pro/types.rb
|
78
80
|
- lib/logic_pro/version.rb
|
79
81
|
- logic_pro.gemspec
|