Class: ExpressionEngine::Preference

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/vendor/preference.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(serialized_data) ⇒ Preference



9
10
11
# File 'lib/vendor/preference.rb', line 9

def initialize(serialized_data)
  @data = PHP.unserialize(serialized_data).symbolize_keys rescue []
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



7
8
9
# File 'lib/vendor/preference.rb', line 7

def data
  @data
end

Instance Method Details

#[](key) ⇒ Object



13
14
15
# File 'lib/vendor/preference.rb', line 13

def [](key)
  @data[key] rescue nil
end

#[]=(key, value) ⇒ Object



17
18
19
# File 'lib/vendor/preference.rb', line 17

def []=(key, value)
  @data[key] = value rescue nil
end

#each(&block) ⇒ Object



21
22
23
# File 'lib/vendor/preference.rb', line 21

def each(&block)
  @data.each(&block) rescue nil
end

#to_sObject



25
26
27
# File 'lib/vendor/preference.rb', line 25

def to_s
  PHP.serialize(@data.stringify_keys) rescue nil
end