Module: Serializable::SingletonMethods

Defined in:
lib/acts_as_serializable.rb

Instance Method Summary collapse

Instance Method Details

#default_serialization_versionObject



72
73
74
# File 'lib/acts_as_serializable.rb', line 72

def default_serialization_version
  @default_serialization_version
end

#default_serialization_version=(new_version) ⇒ Object



76
77
78
79
80
81
82
# File 'lib/acts_as_serializable.rb', line 76

def default_serialization_version=(new_version)
  if new_version.is_a?(Version)
    @default_serialization_version = new_version
  else
    @default_serialization_version = Version.new(new_version)
  end
end

#find_project_serialization_classes(project_path) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/acts_as_serializable.rb', line 51

def find_project_serialization_classes(project_path)
  klass_name = self.name
  serialization_directory = File.expand_path(File.join(project_path, 'serializations', klass_name.underscore))
  if File.exist?(serialization_directory)
    Find.find(serialization_directory) do |path|
      if File.file?(path) && versioned_klass = path.match(SERIALIZED_CLASS_NAME_REGEXP)
        require path
        klass = Serializations.const_get("#{klass_name}").const_get("Version_#{versioned_klass[1]}")
        if klass && klass.respond_to?(:serialize)
          define_local_serialization_method(versioned_klass[1])
        end
      end
    end
  end
  @default_serialization_version = @serialization_versions.last
end

#serialization_versionsObject



68
69
70
# File 'lib/acts_as_serializable.rb', line 68

def serialization_versions
  @serialization_versions
end