tramway 0.2.1.1 → 0.2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f21d3c15fcbad670039714c4661be3546849982618662fec4de88d5fa7f46ce3
4
- data.tar.gz: ed77adc5f2247c5db97e23b0c6706219689afcbbedd02db3597d2e31f1adde23
3
+ metadata.gz: c2ed52c776d761d5afe99a7d31c99084191c032af8f35c13a49f1d3f6155d01f
4
+ data.tar.gz: e6cee0a18222ae4d3a99f63a8b8959bfaec6dab11107006040451254c14aa4b4
5
5
  SHA512:
6
- metadata.gz: 58c2ce7f3f93ae17fd399d1fff01e0abce89f0a687aba960d5431be777f2ec2ae0078d68d9f9bdffadedce5b67004a4a487a30ad29e09e7927fb1b808a83843c
7
- data.tar.gz: 2b1ff7fa17dfb4e8eed897bdaab83b32a58f0230a12a24d2bf37f9334779d7abf180949d50444b0e75623efd9db10a9b116d231a923b16efbb6af507d218a17b
6
+ metadata.gz: 676f475214beb3bab65636d145bf797d48efadf0519294c2551b26caf58c47270238fce3f2a3bb72953a9a8d55708aa88fc4cda61deed86d60cd82f8cbc47bf8
7
+ data.tar.gz: 3f5847c31384d66b892ab8eddec5a730579cd0fcebbf85302316b8f98c00677b7ff3b2c778cdb22e39427c7a3f10baa73c74599c7237c06c9b6a2c24c68fec60
@@ -1,34 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'tramway/decorators/collection_decorator'
4
+ require 'tramway/utils/decorators/render'
4
5
 
5
6
  module Tramway
6
7
  # Provides decorate function for Tramway projects
7
8
  #
8
9
  class BaseDecorator
9
10
  include Tramway::Decorators::CollectionDecorators
11
+ include Tramway::Utils::Decorators::Render
10
12
 
11
- attr_reader :object, :context
13
+ attr_reader :object
12
14
 
13
- def initialize(object, context)
15
+ def initialize(object)
14
16
  @object = object
15
- @context = context
16
- end
17
-
18
- def render(*args)
19
- context.render(*args, layout: false)
20
17
  end
21
18
 
22
19
  class << self
23
- def decorate(object_or_array, context)
20
+ def decorate(object_or_array)
24
21
  if Tramway::Decorators::CollectionDecorators.collection?(object_or_array)
25
22
  Tramway::Decorators::CollectionDecorators.decorate_collection(
26
23
  collection: object_or_array,
27
- context:,
28
24
  decorator: self
29
25
  )
30
26
  else
31
- new(object_or_array, context)
27
+ new(object_or_array)
32
28
  end
33
29
  end
34
30
 
@@ -7,9 +7,9 @@ module Tramway
7
7
  module CollectionDecorators
8
8
  module_function
9
9
 
10
- def decorate_collection(collection:, context:, decorator:)
10
+ def decorate_collection(collection:, decorator:)
11
11
  collection.map do |item|
12
- decorator.decorate item, context
12
+ decorator.decorate item
13
13
  end
14
14
  end
15
15
 
@@ -8,7 +8,9 @@ module Tramway
8
8
  #
9
9
  module DecorateHelper
10
10
  def tramway_decorate(object_or_array, decorator: nil)
11
- Tramway::Decorators::ClassHelper.decorator_class(object_or_array, decorator).decorate object_or_array, self
11
+ return [] if Tramway::Decorators::CollectionDecorators.collection?(object_or_array) && object_or_array.empty?
12
+
13
+ Tramway::Decorators::ClassHelper.decorator_class(object_or_array, decorator).decorate object_or_array
12
14
  end
13
15
  end
14
16
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tramway
4
+ module Utils
5
+ module Decorators
6
+ # Provides helper method render that depends on ActionController::Base.render method
7
+ #
8
+ module Render
9
+ def render(*args)
10
+ ActionController::Base.render(*args, layout: false)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tramway
4
- VERSION = '0.2.1.1'
4
+ VERSION = '0.2.1.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1.1
4
+ version: 0.2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - kalashnikovisme
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-07-01 00:00:00.000000000 Z
12
+ date: 2023-07-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: haml-rails
@@ -94,6 +94,7 @@ files:
94
94
  - lib/tramway/helpers/decorate_helper.rb
95
95
  - lib/tramway/helpers/navbar_helper.rb
96
96
  - lib/tramway/navbar.rb
97
+ - lib/tramway/utils/decorators/render.rb
97
98
  - lib/tramway/version.rb
98
99
  homepage: https://github.com/purple-magic/tramway
99
100
  licenses: