Module: NSConnector::Attaching
- Included in:
- Resource
- Defined in:
- lib/ns_connector/attaching.rb
Overview
Provide attach! and detach! methods
Instance Method Summary collapse
-
#attach!(klass, attachee_id, ids, attributes = nil) ⇒ Object
- Attach any number of ids to klass Arguments
- klass
-
target class to attach to, i.e.
-
#detach!(klass, attachee_id, ids) ⇒ Object
- Unattach any number of ids to klass Arguments
- klass
-
target class to detach from, i.e.
Instance Method Details
#attach!(klass, attachee_id, ids, attributes = nil) ⇒ Object
Attach any number of ids to klass
- Arguments
- klass
-
target class to attach to, i.e. Contact
- attachee_id
-
internal id of the record to make the attach(s) to
- ids
-
array of target ids
- attributes
-
optional attributes for the attach, i.e. => -5
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ns_connector/attaching.rb', line 9 def attach!(klass, attachee_id, ids, attributes = nil) unless ids.kind_of?(Array) then raise ::ArgumentError, 'Expected ids to be an array' end NSConnector::Restlet.execute!( :action => 'attach', :type_id => type_id, :target_type_id => klass.type_id, :attachee_id => attachee_id, :attributes => attributes, :data => ids ) end |
#detach!(klass, attachee_id, ids) ⇒ Object
Unattach any number of ids to klass
- Arguments
- klass
-
target class to detach from, i.e. Contact
- attachee_id
-
internal id of the record to make the detach(s) from
- ids
-
array of target class ids
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ns_connector/attaching.rb', line 29 def detach!(klass, attachee_id, ids) unless ids.kind_of?(Array) then raise ::ArgumentError, 'Expected ids to be an array' end NSConnector::Restlet.execute!( :action => 'detach', :type_id => type_id, :target_type_id => klass.type_id, :attachee_id => attachee_id, :data => ids ) end |