Class: CapsuleCRM::History
- Inherits:
-
Object
- Object
- CapsuleCRM::History
- Extended by:
- ActiveModel::Naming
- Includes:
- ActiveModel::Conversion, ActiveModel::Validations, Associations, Persistence::Deletable, Persistence::Persistable, Querying::Configuration, Querying::FindOne, Serializable
- Defined in:
- lib/capsule_crm/history.rb
Instance Method Summary collapse
- #belongs_to_api_name ⇒ Object
- #belongs_to_id ⇒ Object
-
#creator=(user) ⇒ Object
Public: Set the creator of this history item.
Methods included from Serializable
included, #serializer, #to_capsule_json
Methods included from Querying::Configuration
Methods included from Persistence::Deletable
Methods included from Persistence::Persistable
#build_create_path, #build_update_path, #create_record, included, #new_record?, #persisted?, #save, #save!, #update_attributes, #update_attributes!, #update_record
Instance Method Details
#belongs_to_api_name ⇒ Object
77 78 79 80 81 82 |
# File 'lib/capsule_crm/history.rb', line 77 def belongs_to_api_name { person: 'party', organization: 'party', case: 'case', opportunity: 'opportunity' }.stringify_keys[belongs_to_name] end |
#belongs_to_id ⇒ Object
84 85 86 |
# File 'lib/capsule_crm/history.rb', line 84 def belongs_to_id (party || self.case || opportunity).try(:id) end |
#creator=(user) ⇒ Object
Public: Set the creator of this history item
user - The String username OR a CapsuleCRM::User object
Examples
history = CapsuleCRM::History.new history.creator = ‘a.username’
user = CapsuleCRM::User.find_by_username(‘another.username’) history.creator = user
Returns the CapsuleCRM::History object
69 70 71 72 73 74 75 |
# File 'lib/capsule_crm/history.rb', line 69 def creator=(user) if user.is_a?(String) user = CapsuleCRM::User.find_by_username(user) end @creator = user self end |