Sha256: 566a06100375d483b16b03c8f24f32858832206eb2062b354779abf0f9e4da52

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

module Searchlogic
  class Search
    module ToYaml
      def self.included(klass)
        klass.class_eval do
          yaml_as "tag:ruby.yaml.org,2002:class"
          extend ClassMethods
          include InstanceMethods
        end
      end
      
      module ClassMethods
        def yaml_new(klass, tag, val)
          raise "ass"
        end
      end
      
      module InstanceMethods
        def to_yaml( opts = {} )
          YAML::quick_emit( self, opts ) do |out|
            out.map("tag:ruby.yaml.org,2002:object:Searchlogic::Search") do |map|
              map.add('class_name', klass.name)
              map.add('current_scope', current_scope)
              map.add('conditions', conditions)
            end
          end
        end
        
        def yaml_initialize(taguri, attributes = {})
          self.klass = attributes["class_name"].constantize
          self.current_scope = attributes["current_scope"]
          @conditions ||= {}
          self.conditions = attributes["conditions"]
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
nberger-searchlogic-2.4.29 lib/searchlogic/search/to_yaml.rb
nberger-searchlogic-2.4.28 lib/searchlogic/search/to_yaml.rb
yoomee-searchlogic-2.4.27 lib/searchlogic/search/to_yaml.rb
searchlogic-2.4.26 lib/searchlogic/search/to_yaml.rb