railjet 2.1.1 → 3.0.0

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
  SHA1:
3
- metadata.gz: d092976ecd3a3258ec44edd6c62e1ba88f969444
4
- data.tar.gz: '08158874d5f23f745fb6c98e19e2a2a3e9f4431e'
3
+ metadata.gz: '098b90a736eae576e53de9bfc06a8cdc300d804d'
4
+ data.tar.gz: f31c69ff62c11c2c66833e90c91ab48f86e1bb34
5
5
  SHA512:
6
- metadata.gz: 3f7fbda03ee87bad58bd72dd033e400a46c6d5b9ef77f6d358aa801d1364ea2a5899a2247f3efb87e7f7227ccaec52a34fd39b604be2e5be3e1b25610a19cd1f
7
- data.tar.gz: 8037cc8eeab89a9c69c84e59a2b47629d04dd1870f44830a8252a9d554333e18d3f14d43b1b4efbd686a8534e76a98b982fb1aed41a130972a1d1c3455ed88e6
6
+ metadata.gz: 71fe9cedb8d2362c93890527ab124e4c3c51c893d3708a6d3b4a10464b2620a871d05ec4a4e443b4b90e0e1751a9980d1414a078ae2fac31b0323a64e1b7c200
7
+ data.tar.gz: d53d4a1837cee25e3444c6e600bc3c454e520f11679b17e2d71ee784e83bb78d9993a3dab456c23b1ca790a6c1b1635312ae8b18284ef5153115592c9dcbfb62
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- railjet (2.1.1)
4
+ railjet (3.0.0)
5
5
  activemodel (> 4)
6
6
  activesupport (> 4)
7
7
  validates_timeliness (~> 4.0.2)
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
- # Railjet, architecture for high-speed railway [![Build Status](https://travis-ci.com/nedap/railjet.svg?token=sx7KNHQkbW5qxVMs4wKk&branch=master)](https://travis-ci.com/nedap/railjet)
1
+ # Railjet, architecture for high-speed railway [![Build Status](https://semaphoreci.com/api/v1/nedap/railjet/branches/master/badge.svg)](https://semaphoreci.com/nedap/railjet)
2
+
2
3
 
3
4
  ![Railjet](https://www.swisspasses.com/railpass/popup/railjet/slideshow/RailJet-Zuerich-St.-Anton-Transfer-Ticket-from-Swisspasses.com.jpg)
4
5
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.1
1
+ 3.0.0
@@ -44,6 +44,7 @@ require "railjet/policy"
44
44
  require "railjet/composed_policy"
45
45
  require "railjet/use_case"
46
46
  require "railjet/presenter"
47
+ require "railjet/presenter_context"
47
48
 
48
49
  require "railjet/repository/registry"
49
50
  require "railjet/repository"
@@ -8,25 +8,29 @@ module Railjet
8
8
  @object = object
9
9
  end
10
10
 
11
+ attr_reader :object
12
+
11
13
  def as_json(*)
12
14
  raise NotImplementedError
13
15
  end
14
16
 
15
17
  module ClassMethods
16
18
  def present_collection(objects)
17
- objects.map { |o| new(o) }
19
+ objects.map { |o| present(o) }
18
20
  end
19
21
 
20
- private
22
+ def present(object)
23
+ new(object)
24
+ end
21
25
 
22
- def present(name)
23
- define_method(name) { instance_variable_get(:@object) }
24
- private name
26
+ def object(name)
27
+ alias_method name, :object
25
28
  end
26
29
  end
27
30
 
28
31
  module WithContext
29
32
  extend ActiveSupport::Concern
33
+ include Railjet::Presenter
30
34
 
31
35
  included do
32
36
  attr_reader :context
@@ -40,7 +44,15 @@ module Railjet
40
44
 
41
45
  module ClassMethods
42
46
  def present_collection(context, objects)
43
- objects.map { |o| new(context, o) }
47
+ objects.map { |o| present(context, o) }
48
+ end
49
+
50
+ def present(context, object)
51
+ new(context, object)
52
+ end
53
+
54
+ def context(*context_members)
55
+ delegate *context_members, to: :context
44
56
  end
45
57
  end
46
58
 
@@ -0,0 +1,14 @@
1
+ module Railjet
2
+ class PresenterContext < SimpleDelegator
3
+ attr_reader :view
4
+
5
+ def initialize(context, view_context)
6
+ super(context)
7
+ @view = view_context
8
+ end
9
+
10
+ def repository
11
+ raise NoMethodError, "Acessing Repository from Presenter is a no-no 🙅‍♂️"
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module Railjet
2
- VERSION = "2.1.1"
2
+ VERSION = "3.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railjet
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Zalewski
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-11 00:00:00.000000000 Z
11
+ date: 2019-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -161,7 +161,6 @@ files:
161
161
  - ".rspec"
162
162
  - ".ruby-gemset"
163
163
  - ".ruby-version"
164
- - ".travis.yml"
165
164
  - Gemfile
166
165
  - Gemfile.lock
167
166
  - LICENSE.txt
@@ -186,6 +185,7 @@ files:
186
185
  - lib/railjet/form.rb
187
186
  - lib/railjet/policy.rb
188
187
  - lib/railjet/presenter.rb
188
+ - lib/railjet/presenter_context.rb
189
189
  - lib/railjet/repository.rb
190
190
  - lib/railjet/repository/active_record.rb
191
191
  - lib/railjet/repository/generic.rb
@@ -1,2 +0,0 @@
1
- ---
2
- language: ruby