cyrax 0.2.9 → 0.2.10

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmJkNzJlODY4MTJkNDUyMDY2NDBjYTI4YzA5NmMyNGFmNmYzNWMxMQ==
4
+ ZDZiMThhZWY4ZDM0NGQ2ZWVjNzliZGVlMmQ3MmQ1MjVmODViOWZmZg==
5
5
  data.tar.gz: !binary |-
6
- ZjEyY2ZkNTEyMmU3ZDY3Mjg1MTVlYmFhZWU0MDY5ZjI3YzM3NjE3YQ==
6
+ ZjU4ZWRmNWU3ODA1MTE4OTliMDhjMmU3ZjUxYjRmOWIzY2MwNjRjNw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NTIwZjAzNjJlYWI4OWEwYWEwZTk4OGNhMGU2MTg1NzIxNTJmNTI4NDhmNDQ0
10
- ZmUxYWJjOTIxYTU0YzdjZDViNWZkNDRlOGEwZGMyZDU1ZWRmOWUxN2M4MmNh
11
- ZTIzYzBkNTNiYTY5M2MxYTNmZWVkMTBmMWNlYzM3NWM4YjM3Nzg=
9
+ YzE1MmZiNzA2ZWE2NjhhOGU2Zjg4NWFiODE5ZTEyZGQ2MmM0MmZjZWZlZTA1
10
+ ZDJiOTNhZGU2OGJhMjYwZDAxZDA1ZGRiMTU0MzA4OWViZWZkNDFlZTg0ZDg3
11
+ ZjE4YzA1ZDMzMDk3NjhlMjZlMDM1NmMyMjU4YjQwYmZiOWI1NmY=
12
12
  data.tar.gz: !binary |-
13
- MjUyNDA1Y2I1MjBjYWZhMWRhZDU1YWQ3Zjk1N2IzN2Q5MWVmY2Q0YjVkNzdl
14
- NWE0YjJkNTEyYTcyYWQ0NmU0MmMxYTgxZjk2NTgzYmJiYzYyOWRmYjc5ZTQ2
15
- ZDJjMTUxMTI1MzJmZWNhNTE1NjA5YjMzZDM4NWM0MDhmOTVkMGU=
13
+ MWIxODQ2ZDc4NTZkZGUyNjZkMTkyY2RmYzc5ZDE5MDMyMzU3NjcxMjEyMWNh
14
+ Mjc1YTk3MzljOGY5ZDRiMjc5ZDRkMDc2MjA3YTNmNWU4MmFiNjliODIzMGQz
15
+ YzU2Njg1MjNlNjQ1YWU1ODcwMzVkNmQ0YWE1ZGZhOGNiNWRjNzE=
@@ -19,9 +19,9 @@ class Cyrax::BasePresenter
19
19
 
20
20
  def present_with_decoration(object, options)
21
21
  if options[:present] == :collection
22
- options[:decorator_class].decorate_collection(object)
22
+ options[:decorator].decorate_collection(object)
23
23
  else
24
- options[:decorator_class].decorate(object)
24
+ options[:decorator].decorate(object)
25
25
  end
26
26
  end
27
27
 
@@ -1,10 +1,10 @@
1
1
  class Cyrax::DecoratedCollectionPresenter < Cyrax::BaseCollectionPresenter
2
- attr_reader :decorator_class
2
+ attr_reader :decorator
3
3
 
4
4
  def initialize(collection, options = {})
5
5
  super
6
- @decorator_class = options[:decorator_class]
7
- raise "Decorator class is not defined! Please define it with option :decorator_class" unless decorator_class
6
+ @decorator = options[:decorator]
7
+ raise "Decorator class is not defined! Please define it with option :decorator" unless decorator
8
8
  end
9
9
 
10
10
  class << self
@@ -8,7 +8,10 @@ module Cyrax::Extensions
8
8
  end
9
9
 
10
10
  def assign_resource(resource_name, resource, options = {})
11
- resource = options[:decorator].decorate(resource) if options[:decorator]
11
+ if options[:decorator]
12
+ options.merge!(decorable: true)
13
+ resource = Cyrax::BasePresenter.present(resource, options)
14
+ end
12
15
  @_assignments ||= {}
13
16
  @_assignments[resource_name.to_sym] = resource
14
17
  end
@@ -36,11 +39,12 @@ module Cyrax::Extensions
36
39
 
37
40
  def respond_with(result, options = {})
38
41
  name = options[:name] || response_name
42
+ result = result.result.to_model if result.is_a?(Cyrax::Response)
39
43
  if respond_to?(:decorable?)
40
- options.merge!(decorable: decorable?, decorator_class: decorator_class)
44
+ options.merge!(decorable: decorable?, decorator: decorator_class)
41
45
  result = Cyrax::BasePresenter.present(result, options)
42
46
  end
43
- response = result.is_a?(Cyrax::Response) ? result : Cyrax::Response.new(name, result)
47
+ response = Cyrax::Response.new(name, result)
44
48
  response.message = @_message
45
49
  response.errors = @_errors
46
50
  response.assignments = @_assignments
data/lib/cyrax/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cyrax
2
- VERSION = "0.2.9"
2
+ VERSION = "0.2.10"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cyrax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Droidlabs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-29 00:00:00.000000000 Z
11
+ date: 2013-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport