Module: CouchRest::CastedModel

Defined in:
lib/couchrest/more/casted_model.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
10
# File 'lib/couchrest/more/casted_model.rb', line 7

def self.included(base)
  base.send(:include, ::CouchRest::Mixins::Properties)
  base.send(:attr_accessor, :casted_by)
end

Instance Method Details

#[](key) ⇒ Object



26
27
28
# File 'lib/couchrest/more/casted_model.rb', line 26

def [] key
  super(key.to_s)
end

#[]=(key, value) ⇒ Object



22
23
24
# File 'lib/couchrest/more/casted_model.rb', line 22

def []= key, value
  super(key.to_s, value)
end

#initialize(keys = {}) ⇒ Object

Raises:

  • (StandardError)


12
13
14
15
16
17
18
19
20
# File 'lib/couchrest/more/casted_model.rb', line 12

def initialize(keys={})
  raise StandardError unless self.is_a? Hash
  apply_defaults # defined in CouchRest::Mixins::Properties
  super()
  keys.each do |k,v|
    self[k.to_s] = v
  end if keys
  cast_keys      # defined in CouchRest::Mixins::Properties
end