Module: Slappy::SlackAPI::Findable::ClassMethods
- Defined in:
- lib/slappy/slack_api/concerns/findable.rb
Instance Attribute Summary collapse
-
#api_name ⇒ Object
Returns the value of attribute api_name.
-
#list_name ⇒ Object
Returns the value of attribute list_name.
-
#monitor_event ⇒ Object
Returns the value of attribute monitor_event.
-
#monitor_registerd ⇒ Object
readonly
Returns the value of attribute monitor_registerd.
Instance Method Summary collapse
- #find(arg) ⇒ Object
- #find_by_keyword(hash) ⇒ Object
- #list(options = {}) ⇒ Object
- #register_monitor ⇒ Object
Instance Attribute Details
#api_name ⇒ Object
Returns the value of attribute api_name.
14 15 16 |
# File 'lib/slappy/slack_api/concerns/findable.rb', line 14 def api_name @api_name end |
#list_name ⇒ Object
Returns the value of attribute list_name.
14 15 16 |
# File 'lib/slappy/slack_api/concerns/findable.rb', line 14 def list_name @list_name end |
#monitor_event ⇒ Object
Returns the value of attribute monitor_event.
14 15 16 |
# File 'lib/slappy/slack_api/concerns/findable.rb', line 14 def monitor_event @monitor_event end |
#monitor_registerd ⇒ Object (readonly)
Returns the value of attribute monitor_registerd.
14 15 16 |
# File 'lib/slappy/slack_api/concerns/findable.rb', line 14 def monitor_registerd @monitor_registerd end |
Instance Method Details
#find(arg) ⇒ Object
53 54 55 56 |
# File 'lib/slappy/slack_api/concerns/findable.rb', line 53 def find(arg) return find_by_keyword(arg) if arg.instance_of? Hash find id: arg end |
#find_by_keyword(hash) ⇒ Object
58 59 60 |
# File 'lib/slappy/slack_api/concerns/findable.rb', line 58 def find_by_keyword(hash) hash.map { |key, value| list.find { |obj| obj.send(key) == value } }.first end |
#list(options = {}) ⇒ Object
39 40 41 42 43 |
# File 'lib/slappy/slack_api/concerns/findable.rb', line 39 def list( = {}) register_monitor @list = get_list() unless @list @list end |
#register_monitor ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/slappy/slack_api/concerns/findable.rb', line 29 def register_monitor return if @monitor_registerd @monitor_event.each do |event| Slappy.monitor event do @list = nil end end @monitor_registerd = true end |