trailblazer 0.2.1 → 0.2.2

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: 973befd1d4260ea9bee84355c8b204084a51b5f9
4
- data.tar.gz: 41e5430171b1d65a99716fd0502a9b9c8eb9d078
3
+ metadata.gz: 501c866e1640a0a821e4bbeaa38fbab80ef8c03d
4
+ data.tar.gz: b76816095a34ad206dbf1d74fbefd070957f73f4
5
5
  SHA512:
6
- metadata.gz: a54b22de4bd4966d6045fc78b0a0720fe1d7d4fbfc044115e476eb669fc90cbac645fcb9f780806ddc89c1ac6de7b984341956a703d35954f3e2c5730e64e1cb
7
- data.tar.gz: 495cccf41dbb172fce76dcf9b5b8de68e66961ae78efcc1bfc5491400fa40fb6cb84e9343d56e827fe991f203ea00c6df547299ca13c87c4242126109215bb3a
6
+ metadata.gz: 69aed732717c006c7a32f09fabbaa2ff886cb9fd4d6be4fccdf6dd0f81959415c440470705a008570f5e0ccf9bcc9dadfff4cb19e50babb04c0d2dcf77a75cc3
7
+ data.tar.gz: 769c47a8a86e3777c7bd6f13a4893b3fe969712be3e1eecfdaadd4f013c082d61abe9fbe2ca4a6cdf47bd69fe2e774a3b7cc4927352fe2601fb1a349007f6eff
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.2.2
2
+
3
+ # Added Operation#errors as every operation maintains a contract.
4
+
1
5
  # 0.2.1
2
6
 
3
7
  * Added `Operation#setup_model!(params)` that can be overridden to add nested objects or process models right after `model!`. Don't add deserialization logic here, let Reform/Representable do that.
data/README.md CHANGED
@@ -467,6 +467,10 @@ Override `Operation#setup_model(params)` to add nested objects that can be infer
467
467
 
468
468
  This is called right after `#model!`.
469
469
 
470
+ ### Validation Errors
471
+
472
+ You can access the contracts `Errors` object via `Operation#errors`.
473
+
470
474
  ### ActiveModel Semantics
471
475
 
472
476
  When using `Reform::Form::ActiveModel` (which is used automatically in a Rails environment to make form builders work) you need to invoke `model Comment` in the contract. This can be inferred automatically from the operation by including `CRUD::ActiveModel`.
@@ -76,6 +76,10 @@ module Trailblazer
76
76
 
77
77
  attr_reader :contract
78
78
 
79
+ def errors
80
+ contract.errors
81
+ end
82
+
79
83
  def valid?
80
84
  @valid
81
85
  end
@@ -1,3 +1,3 @@
1
1
  module Trailblazer
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -340,3 +340,21 @@ class OperationInheritanceTest < MiniTest::Spec
340
340
  song.band.must_equal nil
341
341
  end
342
342
  end
343
+
344
+
345
+ class OperationErrorsTest < MiniTest::Spec
346
+ class Operation < Trailblazer::Operation
347
+ contract do
348
+ property :title, validates: {presence: true}
349
+ end
350
+
351
+ def process(params)
352
+ validate(params, OpenStruct.new) {}
353
+ end
354
+ end
355
+
356
+ it do
357
+ res, op = Operation.run({})
358
+ op.errors.to_s.must_equal "{:title=>[\"can't be blank\"]}"
359
+ end
360
+ end
@@ -8,9 +8,9 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Trailblazer::VERSION
9
9
  spec.authors = ["Nick Sutterer"]
10
10
  spec.email = ["apotonick@gmail.com"]
11
- spec.description = %q{Trailblazer is a thin layer on top of Rails. It gently enforces encapsulation, an intuitive code structure and gives you an object-oriented architecture.}
12
- spec.summary = %q{A New Architecture For Rails.}
13
- spec.homepage = ""
11
+ spec.description = %q{A high-level, modular architecture for Rails with domain and form objects, view models, twin decorators and representers.}
12
+ spec.summary = %q{A new architecture for Rails.}
13
+ spec.homepage = "http://www.trailblazerb.org"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trailblazer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-16 00:00:00.000000000 Z
11
+ date: 2015-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -156,8 +156,8 @@ dependencies:
156
156
  - - ">="
157
157
  - !ruby/object:Gem::Version
158
158
  version: '0'
159
- description: Trailblazer is a thin layer on top of Rails. It gently enforces encapsulation,
160
- an intuitive code structure and gives you an object-oriented architecture.
159
+ description: A high-level, modular architecture for Rails with domain and form objects,
160
+ view models, twin decorators and representers.
161
161
  email:
162
162
  - apotonick@gmail.com
163
163
  executables: []
@@ -209,7 +209,7 @@ files:
209
209
  - test/uploaded_file_test.rb
210
210
  - test/worker_test.rb
211
211
  - trailblazer.gemspec
212
- homepage: ''
212
+ homepage: http://www.trailblazerb.org
213
213
  licenses:
214
214
  - MIT
215
215
  metadata: {}
@@ -232,7 +232,7 @@ rubyforge_project:
232
232
  rubygems_version: 2.2.2
233
233
  signing_key:
234
234
  specification_version: 4
235
- summary: A New Architecture For Rails.
235
+ summary: A new architecture for Rails.
236
236
  test_files:
237
237
  - test/crud_test.rb
238
238
  - test/fixtures/apotomo.png