lib/sk_sdk/base.rb in sk_sdk-0.4.2 vs lib/sk_sdk/base.rb in sk_sdk-0.4.3
- old
+ new
@@ -5,19 +5,25 @@
# patches are for specific AR version
case ActiveResource::VERSION::MAJOR
when 3
require 'sk_sdk/ar_patches/ar3/base'
require 'sk_sdk/ar_patches/ar3/validations'
-when 4,5
+when 4,5,6
require 'sk_sdk/ar_patches/ar4/validations'
require 'sk_sdk/ar_patches/ar4/base'
end
class SK::SDK::Base < ActiveResource::Base
self.format = :json
# hook before init in activeresource base because json comes in nested:
# {client={data}
- if (ActiveResource::VERSION::MAJOR == 3 && ActiveResource::VERSION::MINOR > 0) || ActiveResource::VERSION::MAJOR > 3
+ if ActiveResource::VERSION::MAJOR == 6
+ self.include_root_in_json = true
+ def initialize(attributes = {}, persisted=false)
+ attr = attributes[self.class.element_name] || attributes
+ super(attr, persisted)
+ end
+ elsif (ActiveResource::VERSION::MAJOR == 3 && ActiveResource::VERSION::MINOR > 0) || ActiveResource::VERSION::MAJOR < 6
self.include_root_in_json = true
def initialize(attributes = {}, *args)
attr = attributes[self.class.element_name] || attributes
super(attr, *args)
end