tramway 0.2.1.2 → 0.2.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2dd99c95cb679606a69128eb290b9c35fee411dc626ed2f43a1b3cfcba36efa
4
- data.tar.gz: 95ed3ccb11b51c8df14061aa9bc483257da99e05755f06935fd27bfabb3d1393
3
+ metadata.gz: c2ed52c776d761d5afe99a7d31c99084191c032af8f35c13a49f1d3f6155d01f
4
+ data.tar.gz: e6cee0a18222ae4d3a99f63a8b8959bfaec6dab11107006040451254c14aa4b4
5
5
  SHA512:
6
- metadata.gz: d759138c8522fa61b234affae4547f403992ade47ff99413e5abb42cc52101137294dcef77e4f17528d1d6463d8668fa85ef71cd1b0bc6f5042522aa8254fd27
7
- data.tar.gz: 2e63cf0b4fa9122c2f0e97aaad067a7b325c5644a4912c1636f4bc247e1f98dada96991ed231c1ab26d404dec0d719c406bacede57e21331576fbb005fdabf9d
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
 
@@ -10,7 +10,7 @@ module Tramway
10
10
  def tramway_decorate(object_or_array, decorator: nil)
11
11
  return [] if Tramway::Decorators::CollectionDecorators.collection?(object_or_array) && object_or_array.empty?
12
12
 
13
- Tramway::Decorators::ClassHelper.decorator_class(object_or_array, decorator).decorate object_or_array, self
13
+ Tramway::Decorators::ClassHelper.decorator_class(object_or_array, decorator).decorate object_or_array
14
14
  end
15
15
  end
16
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.2'
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.2
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-21 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: