Module: Hws::Transactions
- Defined in:
- lib/hws-transactions.rb,
lib/generators/hws/transactions/install_generator.rb
Overview
:nodoc:
Defined Under Namespace
Modules: Generators, Models
Class Method Summary collapse
-
.add_entry(transaction_group_id, value, txn_time, tags) ⇒ Object
tags: hash of the form mentioned below.
-
.create_group(name, description, mutable_tags, immutable_tags) ⇒ Object
name: name of the journal description: description of the journal mutable_tags: [] immutable_tags: [].
- .get_entry(entry_id) ⇒ Object
- .get_group(id) ⇒ Object
-
.list_entries(transaction_group_id, filters = {}, page_context = {}) ⇒ Object
filters: hash of the form mentioned below.
- .update_entry(transaction_group_id, entry_id, mutable_tags) ⇒ Object
Class Method Details
.add_entry(transaction_group_id, value, txn_time, tags) ⇒ Object
tags: hash of the form mentioned below.
'mutable_tags' => {mutable_tag_key1 => m_tag_val1, mutable_tag_key2 => m_tag_val2,
'immutable_tags' => => i_tag_val1, immutable_tag_key2 => i_tag_val2
}
24 25 26 |
# File 'lib/hws-transactions.rb', line 24 def self.add_entry(transaction_group_id, value, txn_time, ) self.get_group(transaction_group_id).try(:add_entry, value, txn_time, .with_indifferent_access) end |
.create_group(name, description, mutable_tags, immutable_tags) ⇒ Object
name: name of the journal description: description of the journal mutable_tags: [] immutable_tags: []
10 11 12 13 |
# File 'lib/hws-transactions.rb', line 10 def self.create_group(name, description, , ) ::Hws::Transactions::Models::TransactionGroup.create(name: name, description: description, tags: { mutable_tags: , immutable_tags: }.with_indifferent_access) end |
.get_entry(entry_id) ⇒ Object
54 55 56 57 58 |
# File 'lib/hws-transactions.rb', line 54 def self.get_entry(entry_id) entry = ::Hws::Transactions::Models::TransactionEntry.find_by(id: entry_id) { id: entry.id, transaction_group_id: entry.transaction_group_id, value: entry.value, txn_time: entry.txn_time, tags: { immutable_tags: entry., mutable_tags: entry. } } end |
.get_group(id) ⇒ Object
15 16 17 |
# File 'lib/hws-transactions.rb', line 15 def self.get_group(id) ::Hws::Transactions::Models::TransactionGroup.find(id) end |
.list_entries(transaction_group_id, filters = {}, page_context = {}) ⇒ Object
filters: hash of the form mentioned below.
'col1' => 'val1',
'col2' => 'val2',
'mutable_tags' => {
'jsonf1' => 'val1',
'jsonf2' => {'nested_jsonf3' => 'val2'
}
'immutable_tags' => {
'jsonf1' => 'val1',
'jsonf2' => => 'val2'
}
} pagination_context: hash of the form mentioned below. {
'last_entry': '',
'page_size': 10
}
50 51 52 |
# File 'lib/hws-transactions.rb', line 50 def self.list_entries(transaction_group_id, filters = {}, page_context = {}) self.get_group(transaction_group_id).try(:list_entries, filters.with_indifferent_access, page_context.with_indifferent_access) end |
.update_entry(transaction_group_id, entry_id, mutable_tags) ⇒ Object
28 29 30 |
# File 'lib/hws-transactions.rb', line 28 def self.update_entry(transaction_group_id, entry_id, ) self.get_group(transaction_group_id).try(:update_entry, entry_id, .with_indifferent_access) end |