tramway-core 1.18.1.2 → 1.18.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/app/decorators/tramway/core/associations/class_helper.rb +7 -4
- data/app/decorators/tramway/core/associations/object_helper.rb +9 -1
- data/app/uploaders/ico_uploader.rb +7 -0
- data/lib/tramway/core/version.rb +1 -1
- data/lib/tramway/error.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f15409a5475b15fd5f275bebbf8d9017e727e01b66a6f7d5b2f509bdb00e022b
|
4
|
+
data.tar.gz: 6853236cba6a0d4ca13447223b1ffb052bcbe722faae44a30f9ba224f255fcf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3be3d4cc9bc7002fc1885c12e9a7abe239c4b7941f8b88a76d7134a7b6ae5f7438a6c15778648c5cf14988c03dc0702b7baaa65467940af7cac607c5d2c2056e
|
7
|
+
data.tar.gz: e4606632334f0f73294433283b37d0d68be05e1d45fc7c7f31c4e9708d09f7c3aee81a3b424668933a94f42c7aa5eb492aef03b1da619ead5e4a01d5379c10a9
|
data/README.md
CHANGED
@@ -46,6 +46,7 @@ Interface: `uploader(attribute_name, uploader_name, **options)`
|
|
46
46
|
* uploader_name - **short** uploader name. You need to connect uploaders which are compatible with Tramway. Available uploaders:
|
47
47
|
* :photo - you can see it [here](https://github.com/Purple-Magic/tramway-core/blob/develop/app/uploaders/photo_uploader.rb)
|
48
48
|
* :file - you can see it [here](https://github.com/Purple-Magic/tramway-core/blob/develop/app/uploaders/file_uploader.rb)
|
49
|
+
* :ico - you can see [here](https://github.com/Purple-Magic/tramway-core/blob/develop/app/uploaders/ico_uploader.rb)
|
49
50
|
* options - you are available to set options for uploaders exactly for this model. Available options:
|
50
51
|
* versions - **only for :photo**. Set needed versions for file to be cropped. If empty - 0 zero versions will be used. All versions you can see [here](https://github.com/Purple-Magic/tramway-core/blob/develop/app/uploaders/photo_uploader.rb)
|
51
52
|
* extensions - whitelist of file extensions. If empty will be used default whitelist from the uploaders (links above)
|
@@ -29,14 +29,17 @@ module Tramway::Core::Associations::ClassHelper
|
|
29
29
|
def define_main_association_method(association_name, decorator)
|
30
30
|
define_method association_name do
|
31
31
|
association = object.class.reflect_on_association(association_name)
|
32
|
-
|
32
|
+
type = association_type(association)
|
33
|
+
return if association_has_one_without_object(object, association_name, type)
|
33
34
|
|
34
35
|
check_association object, association_name, association
|
35
36
|
decorator_class_name = decorator || decorator_class_name(class_name(association))
|
36
|
-
|
37
|
-
|
37
|
+
case type
|
38
|
+
when :has_many, :has_and_belongs_to_many
|
39
|
+
associations_collection(object, association_name, decorator_class_name)
|
40
|
+
when :belongs_to, :has_one
|
41
|
+
decorator_class_name.decorate(association_object(object, association_name))
|
38
42
|
end
|
39
|
-
return decorator_class_name.decorate object.send association_name if association_type(association).in? [ :belongs_to, :has_one ]
|
40
43
|
end
|
41
44
|
end
|
42
45
|
end
|
@@ -40,11 +40,19 @@ module Tramway::Core::Associations::ObjectHelper
|
|
40
40
|
|
41
41
|
begin
|
42
42
|
form_class.constantize
|
43
|
-
rescue
|
43
|
+
rescue StandardError
|
44
44
|
Tramway::Error.raise_error(
|
45
45
|
:tramway, :core, :associations, :object_helper, :habtm_add_class_not_defined,
|
46
46
|
class: form_class, association_name: association_name
|
47
47
|
)
|
48
48
|
end
|
49
49
|
end
|
50
|
+
|
51
|
+
def association_has_one_without_object(object, association_name, association_type)
|
52
|
+
association_type == :has_one && object.send(association_name).nil?
|
53
|
+
end
|
54
|
+
|
55
|
+
def association_object(object, association_name)
|
56
|
+
object.send association_name
|
57
|
+
end
|
50
58
|
end
|
data/lib/tramway/core/version.rb
CHANGED
data/lib/tramway/error.rb
CHANGED
@@ -22,6 +22,7 @@ class Tramway::Error < RuntimeError
|
|
22
22
|
@errors ||= YAML.load_file("#{Tramway::Core.root}/yaml/errors.yml").with_indifferent_access
|
23
23
|
error = @errors.dig(*coordinates)
|
24
24
|
raise 'Error is not defined in YAML' unless error
|
25
|
+
|
25
26
|
options.each do |pair|
|
26
27
|
error.gsub!("%{#{pair[0]}}", pair[1].to_s)
|
27
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tramway-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.18.
|
4
|
+
version: 1.18.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-05-
|
12
|
+
date: 2020-05-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: audited
|
@@ -361,6 +361,7 @@ files:
|
|
361
361
|
- app/models/tramway/core/application_record.rb
|
362
362
|
- app/uploaders/application_uploader.rb
|
363
363
|
- app/uploaders/file_uploader.rb
|
364
|
+
- app/uploaders/ico_uploader.rb
|
364
365
|
- app/uploaders/image_defaults.rb
|
365
366
|
- app/uploaders/photo_uploader.rb
|
366
367
|
- app/views/tramway/core/404.haml
|