Module: MagickColumns
- Defined in:
- lib/magick_columns/rules.rb,
lib/magick_columns.rb,
lib/magick_columns/i18n.rb,
lib/magick_columns/railtie.rb,
lib/magick_columns/version.rb,
lib/magick_columns/defaults.rb,
lib/magick_columns/tokenizer.rb,
lib/magick_columns/active_record.rb
Overview
TODO: These rules should be added to a live array, not a constant one
Defined Under Namespace
Modules: ActiveRecord, I18n Classes: Railtie, Tokenizer
Constant Summary collapse
- DYNAMIC_READERS =
[ :and_operators, :or_operators, :from_operators, :until_operators, :today_operators ]
- TOKENIZE_RULES =
{ from: { pattern: -> { /(\A\s*|\s+)(#{MagickColumns.from_operators})\s+(\S+)/ }, tokenizer: ->(match) { { operator: '>=', term: match[3] } } }, until:{ pattern: -> { /(\A\s*|\s+)(#{MagickColumns.until_operators})\s+(\S+)/ }, tokenizer: ->(match) { { operator: '<=', term: match[3] } } } }
- REPLACEMENT_RULES =
{ today: { pattern: -> { /#{MagickColumns.today_operators}/ }, replacement: ->(match) { Date.today.to_s(:db) } } }
- VERSION =
'0.0.4'
- DEFAULTS =
{ string: { operator: :like, mask: '%%%{t}%%', condition: ->(t) { t =~ /.+/ }, convert: ->(t) { t.to_s } }, email: { operator: :like, mask: '%%%{t}%%', condition: ->(t) { t =~ /(.+@.*)|(.*@.+)/ }, convert: ->(t) { t.to_s } }, integer: { operator: '=', mask: '%{t}', condition: ->(t) { t =~ /\A\d+\z/ }, convert: ->(t) { t.to_i } }, date: { operator: '=', mask: '%{t}', condition: ->(t) { ::Timeliness.parse(t.to_s) }, convert: ->(t) { ::Timeliness.parse(t.to_s) } } }
- @@and_operators =
_default_setup_for :and
- @@or_operators =
_default_setup_for :or
- @@from_operators =
_default_setup_for :from
- @@until_operators =
_default_setup_for :until
- @@today_operators =
_default_setup_for :today
- @@replacement_rules =
REPLACEMENT_RULES.dup
- @@tokenize_rules =
TOKENIZE_RULES.dup
Class Method Summary collapse
-
.setup {|_self| ... } ⇒ Object
Setup method for plugin configuration.
Class Method Details
.setup {|_self| ... } ⇒ Object
Setup method for plugin configuration
66 67 68 |
# File 'lib/magick_columns.rb', line 66 def self.setup yield self end |