Module: Paperlex::SubObject
- Extended by:
- ActiveSupport::Concern
- Included in:
- Contract::ReviewSessions, Contract::Signatures, Contract::Signers
- Defined in:
- lib/paperlex/base/sub_object.rb
Instance Method Summary collapse
- #all ⇒ Object
- #create(attrs = {}) ⇒ Object
- #destroy(uuid) ⇒ Object
- #find(uuid) ⇒ Object
- #initialize(contract_uuid) ⇒ Object
- #new_object(attrs) ⇒ Object
- #update(uuid, attrs) ⇒ Object
Instance Method Details
#all ⇒ Object
17 18 19 |
# File 'lib/paperlex/base/sub_object.rb', line 17 def all self.class.get(collection_url) end |
#create(attrs = {}) ⇒ Object
21 22 23 24 25 |
# File 'lib/paperlex/base/sub_object.rb', line 21 def create(attrs = {}) attrs.symbolize_keys! attrs.assert_valid_keys(self.class.create_fields) new_object(self.class.post(collection_url, short_name => attrs)) end |
#destroy(uuid) ⇒ Object
35 36 37 |
# File 'lib/paperlex/base/sub_object.rb', line 35 def destroy(uuid) self.class.delete(url_for(uuid)) end |
#find(uuid) ⇒ Object
27 28 29 |
# File 'lib/paperlex/base/sub_object.rb', line 27 def find(uuid) new_object(self.class.get(url_for(uuid))) end |
#initialize(contract_uuid) ⇒ Object
9 10 11 |
# File 'lib/paperlex/base/sub_object.rb', line 9 def initialize(contract_uuid) @contract_uuid = contract_uuid end |
#new_object(attrs) ⇒ Object
13 14 15 |
# File 'lib/paperlex/base/sub_object.rb', line 13 def new_object(attrs) object_class.new(attrs.merge(:contract_uuid => contract_uuid)) end |
#update(uuid, attrs) ⇒ Object
31 32 33 |
# File 'lib/paperlex/base/sub_object.rb', line 31 def update(uuid, attrs) new_object(self.class.put(url_for(uuid), short_name => attrs)) end |