cyrax 0.3.8 → 0.4.0.beta

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NGUwYzA1NjdmZDE3NTA2M2EzNDMzN2RmNmE3NWU3YmZjYTdjYWQ0NA==
4
+ NTJkY2U0ODEzYTY3NzYzNGFjZWIwMWUwMDEwNDM1ZGY4MjBlZTZmYQ==
5
5
  data.tar.gz: !binary |-
6
- ZTM5YWUzZWQ4YjViY2ZmZmY4MWMzZTI2NDgxNzIxNjNjZTAxNDBhZQ==
6
+ ZmQwYzVlNWI1Y2RjYzAwNGQ1ZmJiYjYxZjk5NjI0ZmEyM2NlMTZjYw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- Yzg2M2I5MzRlYjhjYWNlMTZmZTczYTZhNTA4YjEzN2YwZjk1OWE5OWY2M2Y1
10
- M2E1ZmVmNDI2NjM0MzI3Y2FmZDE4Y2YyNWMwNWIwOTAyY2Q2YjA1NWZiNDcz
11
- YTAwMmFhMmUzZDA3ODYyYTEyMDQ1MWUyMjg5N2U2NmVhNzBmODg=
9
+ OGQyYWE3NzU4NjZkMTE3NzE4Mzc3Y2I0MDUxMTNmMGFiNjQzYTg1NGYzNTk1
10
+ OTQyNjNmZmM1Yzg4ZWJlY2I5NWNjNzYxZjc0OTFhNmRkYTRkYmFiODBkYWM3
11
+ MzU0OGI0YjUwMjU2OTk0ZjkzYmZiYzFiOTk1YWJiOWMzZTE4YzA=
12
12
  data.tar.gz: !binary |-
13
- YjYzNWRjZDgxMmMxYThhNDI4MWFhMGNkZGI1ZGIzZmZiYTE0MDdiZTQ2MmQw
14
- MzIyZjQ2YTc4YzU4MzgyNjNiNmNkNzJkM2JjZTFlNTliZjE3NzBmNmUwN2Rj
15
- OGRjZDI3OGFhMzNmNTBhNGYzNWI1NmMxMTAzYmQzN2NkOGIyOGU=
13
+ ZTZiODY0ZDRkZTAxYTk2ZjcwNWI5YTBhNThkY2Q2MTQ5Njk1YjljMDgzN2Q2
14
+ ZmZlYjMzNjJiYmMyNDBmM2U1YThlMWQ0ZWY1MjAwNDlhYTg4MmJmYzgwNjk5
15
+ ZGMyODdhOTA1MTU5NTAwMmYwZmRmMWYyYzFmYmUxZDRmYTJhYjg=
data/lib/cyrax.rb CHANGED
@@ -19,7 +19,7 @@ require "cyrax/decorator.rb"
19
19
  require "cyrax/serializer.rb"
20
20
 
21
21
  module Cyrax
22
- @@strong_parameters = false
22
+ @@strong_parameters = true
23
23
 
24
24
  def self.strong_parameters
25
25
  @@strong_parameters
data/lib/cyrax/base.rb CHANGED
@@ -3,18 +3,21 @@ class Cyrax::Base
3
3
  include HasActiveLogger::Mixin
4
4
  include Cyrax::Extensions::HasResponse
5
5
 
6
- attr_accessor :params, :accessor
6
+ attr_accessor :params, :accessor, :options
7
7
 
8
8
  # Creates a new Cyrax resource
9
9
  #
10
10
  # @param options [Hash] Options to pass in. You need `:as` and `:params`
11
11
  # :as defines the accessor
12
12
  # :params are parameters passed by the controller usually
13
+ # :serializer overrides resource serializer
14
+ # :decorator overrides resource serializer
13
15
  #
14
16
  # @example Instantiating a new resource
15
17
  # Products::UserResource.new(as: current_user, params: params)
16
18
  def initialize(options = {})
17
19
  @accessor = options[:as]
18
20
  @params = options[:params]
21
+ @options = options
19
22
  end
20
23
  end
@@ -6,12 +6,16 @@ module Cyrax::Extensions
6
6
  class_attribute :decorator_class_name
7
7
  end
8
8
 
9
+ def decorator_class_name
10
+ options[:decorator] || self.class.decorator_class_name
11
+ end
12
+
9
13
  def decorable?
10
- !self.class.decorator_class_name.nil?
14
+ !decorator_class_name.nil?
11
15
  end
12
16
 
13
17
  def decorator_class
14
- self.class.decorator_class_name.to_s.classify.constantize
18
+ decorator_class_name.to_s.classify.constantize
15
19
  end
16
20
 
17
21
  module ClassMethods
@@ -6,12 +6,16 @@ module Cyrax::Extensions
6
6
  class_attribute :serializer_class_name
7
7
  end
8
8
 
9
+ def serializer_class_name
10
+ options[:serializer] || self.class.serializer_class_name
11
+ end
12
+
9
13
  def serializable?
10
- !self.class.serializer_class_name.nil?
14
+ !serializer_class_name.nil?
11
15
  end
12
16
 
13
17
  def serializer_class
14
- self.class.serializer_class_name.to_s.classify.constantize
18
+ serializer_class_name.to_s.classify.constantize
15
19
  end
16
20
 
17
21
  module ClassMethods
data/lib/cyrax/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cyrax
2
- VERSION = "0.3.8"
2
+ VERSION = "0.4.0.beta"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cyrax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.4.0.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Droidlabs
@@ -206,9 +206,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
206
206
  version: '0'
207
207
  required_rubygems_version: !ruby/object:Gem::Requirement
208
208
  requirements:
209
- - - ! '>='
209
+ - - ! '>'
210
210
  - !ruby/object:Gem::Version
211
- version: '0'
211
+ version: 1.3.1
212
212
  requirements: []
213
213
  rubyforge_project:
214
214
  rubygems_version: 2.0.5