Sha256: da859b6a3a597a7d279d3ffd03189cef079d02dd03d545ac08684e504773829f

Contents?: true

Size: 576 Bytes

Versions: 18

Compression:

Stored size: 576 Bytes

Contents

module Pickle
  module Session
    # add ability to parse model names as fields, using a session
    module Parser
      def self.included(parser_class)
        parser_class.alias_method_chain :parse_field, :model
      end

      attr_accessor :session

      def match_field
        "(?:\\w+: (?:#{match_model}|#{match_value}))"
      end

      def parse_field_with_model(field)
        if session && field =~ /^(\w+): #{capture_model}$/
          {$1 => session.model($2)}
        else
          parse_field_without_model(field)
        end
      end    
    end
  end
end

Version data entries

18 entries across 18 versions & 3 rubygems

Version Path
ianwhite-pickle-0.1.10 lib/pickle/session/parser.rb
ianwhite-pickle-0.1.11 lib/pickle/session/parser.rb
ianwhite-pickle-0.1.12 lib/pickle/session/parser.rb
ianwhite-pickle-0.1.13 lib/pickle/session/parser.rb
ianwhite-pickle-0.1.14 lib/pickle/session/parser.rb
ianwhite-pickle-0.1.15 lib/pickle/session/parser.rb
ianwhite-pickle-0.1.6 lib/pickle/session/parser.rb
ianwhite-pickle-0.1.8 lib/pickle/session/parser.rb
ianwhite-pickle-0.1.9 lib/pickle/session/parser.rb
mrflip-pickle-0.1.13 lib/pickle/session/parser.rb
pickle-0.1.23 lib/pickle/session/parser.rb
pickle-0.1.22 lib/pickle/session/parser.rb
pickle-0.1.21 lib/pickle/session/parser.rb
pickle-0.1.20 lib/pickle/session/parser.rb
pickle-0.1.19 lib/pickle/session/parser.rb
pickle-0.1.18 lib/pickle/session/parser.rb
pickle-0.1.17 lib/pickle/session/parser.rb
pickle-0.1.16 lib/pickle/session/parser.rb