Module: NextErpBridge::Core::Entry::InstanceMethods
- Defined in:
- lib/next_erp_bridge/core/entry.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
Instance Method Summary collapse
- #before_action ⇒ Object
- #client ⇒ Object
- #doctype ⇒ Object
- #encoded_doctype ⇒ Object
- #rename(new_name, force = false, merge = false, ignore_permissions = false) ⇒ Object
- #save ⇒ Object
- #update(attrs) ⇒ Object
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
74 75 76 |
# File 'lib/next_erp_bridge/core/entry.rb', line 74 def errors @errors end |
Instance Method Details
#before_action ⇒ Object
80 81 82 |
# File 'lib/next_erp_bridge/core/entry.rb', line 80 def before_action self.class.before_action end |
#client ⇒ Object
76 77 78 |
# File 'lib/next_erp_bridge/core/entry.rb', line 76 def client self.class.client end |
#doctype ⇒ Object
84 85 86 |
# File 'lib/next_erp_bridge/core/entry.rb', line 84 def doctype self.class.doctype end |
#encoded_doctype ⇒ Object
88 89 90 |
# File 'lib/next_erp_bridge/core/entry.rb', line 88 def encoded_doctype self.class.encoded_doctype end |
#rename(new_name, force = false, merge = false, ignore_permissions = false) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/next_erp_bridge/core/entry.rb', line 99 def rename(new_name, force=false, merge=false, =false) before_action res = client.api_method('frappe.model.rename_doc.rename_doc', { doctype: doctype, old: self.name, new: new_name, force: force, merge: merge, ignore_permissions: }) if res && res['message'] self.name = res['message'] else false end end |
#save ⇒ Object
116 117 118 119 120 121 |
# File 'lib/next_erp_bridge/core/entry.rb', line 116 def save before_action Util.instance_update(self, client.update(attributes.merge(id: attributes['name'], doctype: encoded_doctype))) !errors.present? end |
#update(attrs) ⇒ Object
92 93 94 95 96 97 |
# File 'lib/next_erp_bridge/core/entry.rb', line 92 def update(attrs) before_action attrs.merge!({ doctype: encoded_doctype, id: attributes['name'] }) Util.instance_update(self, client.update(attrs)) !errors.present? end |