Sha256: 6cbea29a7649b62b370d1a39e68c445d5ea539decca34f9bba84d7247727ccb1

Contents?: true

Size: 360 Bytes

Versions: 4

Compression:

Stored size: 360 Bytes

Contents

class LabelFilter < Array
  def initialize(filter_query)
    label_ids = (filter_query || "").split('-').map{|id| id.to_i}
    super(label_ids)
  end
  def to_condition
    "labelings.label_id IN(#{self.join(',')})"
  end
  def to_query_include(id)
    (self + [id]).join('-')
  end
  def to_query_exclude(id)
    self.reject{|i| i == id}.join('-')
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fassets_core-0.4.0 app/models/label_filter.rb
fassets_core-0.3.1 app/models/label_filter.rb
fassets_core-0.3.0 app/models/label_filter.rb
fassets_core-0.2.0 app/models/label_filter.rb