Module: Serializable

Defined in:
lib/acts_as_serializable.rb,
lib/serializable/version.rb,
lib/serializable/versions.rb,
lib/serializable/xbuilder.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods, SingletonMethods Classes: Version, Versions, XBuilder

Constant Summary collapse

SERIALIZE_TO_VERSION_REGEXP =
/^serialize_to_version_((:?\d+_?)+)$/
SERIALIZED_CLASS_NAME_REGEXP =
/\/version_((:?\d+_?)+)\.rb$/
SERIALIZATION_PROJECT_PATHS =
Serializable.scan_rails_app_paths

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



15
16
17
# File 'lib/acts_as_serializable.rb', line 15

def self.included(base)
  base.extend(ClassMethods)
end

.scan_rails_app_pathsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/acts_as_serializable.rb', line 19

def self.scan_rails_app_paths
  if defined?(RAILS_ROOT)
    # Rails plugin usage
    project_paths = Array.new
    # The app directory itself is not in $LOAD_PATH in Rails 3
    project_paths << Rails.root.join('app') if defined?(Rails) && File.exists?(Rails.root.join('app'))
    $LOAD_PATH.each do |path|
      if path.match(/#{Regexp.escape(RAILS_ROOT)}.*\/app$/)
        project_paths << path
      end
    end
    project_paths
  else
    Array.new
  end
end