Class: Slack::BlockKit::CompositionObjects::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/slack/block_kit/composition_objects/filter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFilter

Returns a new instance of Filter.



18
19
20
# File 'lib/slack/block_kit/composition_objects/filter.rb', line 18

def initialize
  @include = TypeRestrictedArray.new(String)
end

Instance Attribute Details

#exclude_bot_usersObject (readonly)

Returns the value of attribute exclude_bot_users.



8
9
10
# File 'lib/slack/block_kit/composition_objects/filter.rb', line 8

def exclude_bot_users
  @exclude_bot_users
end

#exclude_external_shared_channelsObject (readonly)

Returns the value of attribute exclude_external_shared_channels.



8
9
10
# File 'lib/slack/block_kit/composition_objects/filter.rb', line 8

def exclude_external_shared_channels
  @exclude_external_shared_channels
end

#includeObject (readonly)

Returns the value of attribute include.



8
9
10
# File 'lib/slack/block_kit/composition_objects/filter.rb', line 8

def include
  @include
end

Class Method Details

.[](hash) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/slack/block_kit/composition_objects/filter.rb', line 10

def self.[](hash)
  new.tap do |object|
    hash[:include].each(&object.include.method(:<<))
    object.exclude_external_shared_channels! if hash[:exclude_external_shared_channels]
    object.exclude_bot_users! if hash[:exclude_bot_users]
  end
end

Instance Method Details

#exclude_bot_users!Object



26
27
28
# File 'lib/slack/block_kit/composition_objects/filter.rb', line 26

def exclude_bot_users!
  @exclude_bot_users = true
end

#exclude_external_shared_channels!Object



22
23
24
# File 'lib/slack/block_kit/composition_objects/filter.rb', line 22

def exclude_external_shared_channels!
  @exclude_external_shared_channels = true
end

#to_hObject



30
31
32
33
34
# File 'lib/slack/block_kit/composition_objects/filter.rb', line 30

def to_h
  { include: self.include,
    exclude_external_shared_channels: exclude_external_shared_channels,
    exclude_bot_users: exclude_bot_users }.compact
end