Sha256: 29c587b4295dfef866b625359965f077e9597a14fc5edf83f58459856685a2a9

Contents?: true

Size: 897 Bytes

Versions: 20

Compression:

Stored size: 897 Bytes

Contents

module Searchlogic
  class Search
    module ToYaml
      def self.included(klass)
        klass.class_eval do
          yaml_as "tag:ruby.yaml.org,2002:class"
          include InstanceMethods
        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

20 entries across 20 versions & 1 rubygems

Version Path
searchlogic-2.5.19 lib/searchlogic/search/to_yaml.rb
searchlogic-2.5.18 lib/searchlogic/search/to_yaml.rb
searchlogic-2.5.17 lib/searchlogic/search/to_yaml.rb
searchlogic-2.5.16 lib/searchlogic/search/to_yaml.rb
searchlogic-2.5.15 lib/searchlogic/search/to_yaml.rb
searchlogic-2.5.14 lib/searchlogic/search/to_yaml.rb
searchlogic-2.5.13 lib/searchlogic/search/to_yaml.rb
searchlogic-2.5.12 lib/searchlogic/search/to_yaml.rb
searchlogic-2.5.11 lib/searchlogic/search/to_yaml.rb
searchlogic-2.5.10 lib/searchlogic/search/to_yaml.rb
searchlogic-2.5.9 lib/searchlogic/search/to_yaml.rb
searchlogic-2.5.8 lib/searchlogic/search/to_yaml.rb
searchlogic-2.5.7 lib/searchlogic/search/to_yaml.rb
searchlogic-2.5.6 lib/searchlogic/search/to_yaml.rb
searchlogic-2.5.5 lib/searchlogic/search/to_yaml.rb
searchlogic-2.5.4 lib/searchlogic/search/to_yaml.rb
searchlogic-2.5.3 lib/searchlogic/search/to_yaml.rb
searchlogic-2.5.2 lib/searchlogic/search/to_yaml.rb
searchlogic-2.5.1 lib/searchlogic/search/to_yaml.rb
searchlogic-2.5.0 lib/searchlogic/search/to_yaml.rb