lib/active_remote/base.rb in active_remote-2.3.2 vs lib/active_remote/base.rb in active_remote-2.3.3.pre
- old
+ new
@@ -13,17 +13,24 @@
require 'active_remote/publication'
require 'active_remote/rpc'
require 'active_remote/scope_keys'
require 'active_remote/search'
require 'active_remote/serialization'
+require 'active_remote/typecasting'
require 'active_remote/validations'
module ActiveRemote
class Base
extend ActiveModel::Callbacks
- include ActiveAttr::Model
+ include ActiveAttr::BasicModel
+ include ActiveAttr::BlockInitialization
+ include ActiveAttr::Logger
+ include ActiveAttr::MassAssignment
+ include ActiveAttr::AttributeDefaults
+ include ActiveAttr::QueryAttributes
+ include ActiveAttr::Serialization
include Association
include Attributes
include Bulk
include DSL
@@ -33,10 +40,11 @@
include Publication
include RPC
include ScopeKeys
include Search
include Serialization
+ include Typecasting
# Overrides some methods, providing support for dirty tracking,
# so it needs to be included last.
include Dirty
@@ -47,10 +55,14 @@
attr_reader :last_request, :last_response
define_model_callbacks :initialize, :only => :after
def initialize(*)
- @attributes ||= {}
+ @attributes ||= begin
+ attribute_names = self.class.attribute_names
+ Hash[attribute_names.map { |key| [key, send(key)] }]
+ end
+
@new_record = true
skip_dirty_tracking do
run_callbacks :initialize do
super