Sha256: 8cc4016ad81e86d8af4cbdbcf05c1b8e2287fe13c7f9683b8f7826ac640925c7

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 Bytes

Contents

require 'sakuramochi/predicate'

module Sakuramochi
  class Configuration
    attr_accessor :predicates

    def initialize
      @predicates = {}
    end 

    def add(*args)
      options = args.extract_options!
      options.reverse_merge!(:grouping => true)

      suffixes = [nil]
      suffixes += ['any', 'all'] if options[:grouping]

      args.flatten.each do |name|
        name = name.to_s
        suffixes.each do |suffix|
          predicate_name = [name, suffix].compact.join('_')
          @predicates[predicate_name] = Predicate.new(options.merge({
            :name => predicate_name,
            :arel_predicate => [options[:arel_predicate], suffix].compact.join('_')
          }))
        end
      end 
    end 
  end 
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sakuramochi-0.5.6 lib/sakuramochi/configuration.rb