# Class EventFilter < Object

- lib/event_filter.rb

Methods

A
  - active?,
  - apply_filter
C
  - comments
D
  - default_filter
M
  - merged
N
  - new
O
  - options
P
  - push
T
  - team

Attributes

[RW] | params |

Class Public methods
comments() Link

Source: show

    # File lib/event_filter.rb, line 17
    def comments
      'comments'
    end

default_filter() Link

Source: show

    # File lib/event_filter.rb, line 5
    def default_filter
      %w{ push issues merge_requests team}
    end

merged() Link

Source: show

    # File lib/event_filter.rb, line 13
    def merged
      'merged'
    end

new(params) Link

Source: show

    # File lib/event_filter.rb, line 26
    def initialize params
      @params = if params
                  params.dup
                else
                  []#EventFilter.default_filter
                end
    end

push() Link

Source: show

    # File lib/event_filter.rb, line 9
    def push
      'push'
    end

team() Link

Source: show

    # File lib/event_filter.rb, line 21
    def team
      'team'
    end

Instance Public methods
active?(key) Link

Source: show

    # File lib/event_filter.rb, line 65
    def active? key
      params.include? key
    end

apply_filter(events) Link

Source: show

    # File lib/event_filter.rb, line 34
    def apply_filter events
      return events unless params.present?

      filter = params.dup

      actions = []
      actions << Event::Pushed if filter.include? 'push'
      actions << Event::Merged if filter.include? 'merged'

      if filter.include? 'team'
        actions << Event::Joined
        actions << Event::Left
      end

      actions << Event::Commented if filter.include? 'comments'

      events = events.where(action: actions)
    end

options(key) Link

Source: show

    # File lib/event_filter.rb, line 53
    def options key
      filter = params.dup

      if filter.include? key
        filter.delete key
      else
        filter << key
      end

      filter
    end