module HolidayStore
Constants
- PLUGIN
- STATE_KEY
Public Instance Methods
Source
# File lib/holiday_store.rb, line 45 def announced?(state, key) Array(state["announced"]).include?(key.to_s) end
Source
# File lib/holiday_store.rb, line 12 def default_state { "country" => HolidayCalendar::DEFAULT_COUNTRY, "last_check_at" => nil, "announced" => [], "cache" => { "country" => nil, "year" => nil, "holidays" => [] } } end
Source
# File lib/holiday_store.rb, line 25 def load_state(network:, channel:, store: RabbotDb) store.get_plugin_json( plugin: PLUGIN, key: STATE_KEY, network: network, channel: channel, default: nil ) || default_state end
Source
# File lib/holiday_store.rb, line 49 def mark_announced(state, key) keys = Array(state["announced"]) value = key.to_s return state if keys.include?(value) state.merge("announced" => keys + [value]) end
Source
# File lib/holiday_store.rb, line 35 def save_state(network:, channel:, state:, store: RabbotDb) store.set_plugin_json( plugin: PLUGIN, key: STATE_KEY, network: network, channel: channel, value: state ) end