Module: ModernTimes::MarshalStrategy
- Defined in:
- lib/modern_times/marshal_strategy.rb,
lib/modern_times/marshal_strategy/bson.rb,
lib/modern_times/marshal_strategy/json.rb,
lib/modern_times/marshal_strategy/ruby.rb,
lib/modern_times/marshal_strategy/yaml.rb,
lib/modern_times/marshal_strategy/string.rb
Defined Under Namespace
Modules: BSON, JSON, Ruby, String, YAML
Class Method Summary
collapse
Class Method Details
.find(marshaler) ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'lib/modern_times/marshal_strategy.rb', line 27
def self.find(marshaler)
if marshaler.nil?
return Ruby
else
val = @options[marshaler.to_sym]
return val if val
end
raise "Invalid marshal strategy: #{marshaler}"
end
|
.register(hash) ⇒ Object
Allow user-defined marshal strategies
42
43
44
45
46
47
|
# File 'lib/modern_times/marshal_strategy.rb', line 42
def self.register(hash)
hash.each do |key, marshaler|
raise "Invalid marshal strategy: #{marshaler}" unless valid?(marshaler)
@options[key] = marshaler
end
end
|
.registered?(marshaler) ⇒ Boolean
37
38
39
|
# File 'lib/modern_times/marshal_strategy.rb', line 37
def self.registered?(marshaler)
@options.has_key?(marshaler.to_sym)
end
|
.unregister(sym) ⇒ Object
49
50
51
|
# File 'lib/modern_times/marshal_strategy.rb', line 49
def self.unregister(sym)
@options.delete(sym)
end
|
.valid?(marshaler) ⇒ Boolean
53
54
55
56
57
|
# File 'lib/modern_times/marshal_strategy.rb', line 53
def self.valid?(marshaler)
return marshaler.respond_to?(:marshal_type) &&
marshaler.respond_to?(:marshal) &&
marshaler.respond_to?(:unmarshal)
end
|