Class: ActiveRemote::Base

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Callbacks, ActiveModel::Naming
Includes:
ActiveModel::Conversion, ActiveModel::Validations, ActiveModel::Validations::Callbacks, Association, AttributeAssignment, Attributes, DSL, Dirty, Integration, Persistence, PrimaryKey, QueryAttributes, RPC, ScopeKeys, Search, Serialization, Typecasting, Validations
Defined in:
lib/active_remote/base.rb

Constant Summary

Constants included from Typecasting

Typecasting::TYPECASTER_MAP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validations

#save, #save!, #valid?

Methods included from Dirty

#disable_dirty_tracking, #enable_dirty_tracking, #reload, #save, #save!, #skip_dirty_tracking

Methods included from Serialization

#add_errors

Methods included from Search

#reload

Methods included from ScopeKeys

#scope_key_hash, #scope_keys

Methods included from RPC

#remote_call, #rpc

Methods included from QueryAttributes

#query_attribute

Methods included from PrimaryKey

#primary_key

Methods included from Persistence

#delete, #delete!, #destroy, #destroy!, #has_errors?, #instantiate, #new_record?, #persisted?, #readonly!, #readonly?, #save, #save!, #success?, #update_attribute, #update_attributes, #update_attributes!

Methods included from Integration

#cache_key, #to_param

Methods included from Attributes

#==, #attribute, #attribute=, #attribute_method?, #attributes, #inspect, #read_attribute, #write_attribute

Methods included from AttributeAssignment

#assign_attributes

Constructor Details

#initialize(attributes = {}) ⇒ Base

Returns a new instance of Base.



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/active_remote/base.rb', line 55

def initialize(attributes = {})
  @attributes = self.class.send(:default_attributes_hash).dup

  assign_attributes(attributes) if attributes

  @new_record = true

  skip_dirty_tracking do
    run_callbacks :initialize do
      yield self if block_given?
    end
  end
end

Instance Attribute Details

#last_requestObject (readonly)

Returns the value of attribute last_request.



51
52
53
# File 'lib/active_remote/base.rb', line 51

def last_request
  @last_request
end

#last_responseObject (readonly)

Returns the value of attribute last_response.



51
52
53
# File 'lib/active_remote/base.rb', line 51

def last_response
  @last_response
end

Instance Method Details

#freezeObject



80
81
82
# File 'lib/active_remote/base.rb', line 80

def freeze
  @attributes.freeze; self
end

#frozen?Boolean

Returns:



84
85
86
# File 'lib/active_remote/base.rb', line 84

def frozen?
  @attributes.frozen?
end

#init_with(attributes) ⇒ Object

Initialize an object with the attributes hash directly When used with allocate, bypasses initialize



71
72
73
74
75
76
77
78
# File 'lib/active_remote/base.rb', line 71

def init_with(attributes)
  @attributes = attributes
  @new_record = false

  run_callbacks :initialize

  self
end