Class: ActsAsIcontact::ContactHistory
- Defined in:
- lib/acts_as_icontact/resources/contact_history.rb
Overview
The read-only list of actions attached to every Contact. Because of this intrinsic association, the usual #find methods don’t work; contact history must be obtained using the individual contact’s #history method.
Property updates and saving are also prohibited (returning a ReadOnlyError exception.)
Instance Attribute Summary collapse
-
#parent ⇒ Object
(also: #contact)
readonly
Returns the value of attribute parent.
Class Method Summary collapse
-
.cannot_query(*arguments) ⇒ Object
(also: all, first, find)
Replace all search methods with an exception.
-
.scoped_find(parent, options = {}) ⇒ Object
Returns the ContactHistory collection for the passed contact.
Instance Method Summary collapse
-
#cannot_save(*arguments) ⇒ Object
(also: #save, #save!)
Replace save methods with an exception.
-
#initialize(properties = {}) ⇒ ContactHistory
constructor
Should only be called by ResourceCollection.
-
#method_missing(method, *params) ⇒ Object
Properties of this class are read-only.
Methods inherited from Resource
#==, #connection, #error, #errors, find_by_id, #id, #inspect, #new_record?, #property_names
Constructor Details
#initialize(properties = {}) ⇒ ContactHistory
Should only be called by ResourceCollection. Raises an exception if a parent object is not passed.
10 11 12 13 |
# File 'lib/acts_as_icontact/resources/contact_history.rb', line 10 def initialize(properties={}) @parent = properties.delete(:parent) or raise ActsAsIcontact::ValidationError, "Contact History requires a Contact" super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *params) ⇒ Object
Properties of this class are read-only.
16 17 18 19 |
# File 'lib/acts_as_icontact/resources/contact_history.rb', line 16 def method_missing(method, *params) raise ActsAsIcontact::ReadOnlyError, "Contact History is read-only!" if method.to_s =~ /(.*)=$/ super end |
Instance Attribute Details
#parent ⇒ Object (readonly) Also known as: contact
Returns the value of attribute parent.
6 7 8 |
# File 'lib/acts_as_icontact/resources/contact_history.rb', line 6 def parent @parent end |
Class Method Details
.cannot_query(*arguments) ⇒ Object Also known as: all, first, find
Replace all search methods with an exception
35 36 37 |
# File 'lib/acts_as_icontact/resources/contact_history.rb', line 35 def cannot_query(*arguments) raise ActsAsIcontact::QueryError, "Contact History must be obtained using the contact.history method." end |
.scoped_find(parent, options = {}) ⇒ Object
Returns the ContactHistory collection for the passed contact. Takes the usual iContact search parameters.
23 24 25 26 27 28 29 30 |
# File 'lib/acts_as_icontact/resources/contact_history.rb', line 23 def self.scoped_find(parent, = {}) = .merge() () uri_extension = uri_component + build_query() response = parent.connection[uri_extension].get parsed = JSON.parse(response) ResourceCollection.new(self, parsed, :parent => parent) end |
Instance Method Details
#cannot_save(*arguments) ⇒ Object Also known as: save, save!
Replace save methods with an exception
44 45 46 |
# File 'lib/acts_as_icontact/resources/contact_history.rb', line 44 def cannot_save(*arguments) raise ActsAsIcontact::ReadOnlyError, "Contact History is read-only!" end |