Class: ICalPal::Store
Overview
Class representing items from the Store table
Constant Summary collapse
- QUERY =
<<~SQL.freeze SELECT DISTINCT s1.name AS account, s1.owner_name AS owner, s1.notes, s1.type, (SELECT json_group_array(name) FROM #{self.name.split('::').last} s2 WHERE s2.delegated_account_owner_store_id == s1.external_id ) AS delegations FROM #{self.name.split('::').last} s1 SQL
Constants included from ICalPal
Instance Attribute Summary
Attributes included from ICalPal
Instance Method Summary collapse
- #[](k) ⇒ Object
-
#initialize(obj) ⇒ Store
constructor
A new instance of Store.
Methods included from ICalPal
#<=>, #[]=, call, #dump, #keys, load_data, nth, #to_csv, #to_xml, #values
Constructor Details
#initialize(obj) ⇒ Store
Returns a new instance of Store.
18 19 20 21 22 23 |
# File 'lib/store.rb', line 18 def initialize(obj) super # Convert JSON arrays to Arrays @self['delegations'] = JSON.parse(obj['delegations']).sort if obj['delegations'] end |
Instance Method Details
#[](k) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/store.rb', line 6 def [](k) case k when 'name', 'title' # Aliases @self['account'] when 'owner' # Owner iff there is an account (@self['owner'] == @self['account'])? nil : @self['owner'] else @self[k] end end |