Sha256: eb8db01e1c817324e2b0720c871533063cc1e121d1950a26519cb7c6ed1c0f5a

Contents?: true

Size: 579 Bytes

Versions: 5

Compression:

Stored size: 579 Bytes

Contents

module Pickle
  class Parser
    # add ability to parse model names as fields, using a session
    module WithSession
      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

5 entries across 5 versions & 3 rubygems

Version Path
ianwhite-pickle-0.1.5 lib/pickle/parser/with_session.rb
schlick-pickle-0.1.5.1 lib/pickle/parser/with_session.rb
schlick-pickle-0.1.5.2 lib/pickle/parser/with_session.rb
schlick-pickle-0.1.5.3 lib/pickle/parser/with_session.rb
schlick-schlick-pickle-0.1.5.1 lib/pickle/parser/with_session.rb