Class: EWS::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/ews/model.rb

Direct Known Subclasses

Attachment, Folder, Message

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Model

Returns a new instance of Model.



4
5
6
# File 'lib/ews/model.rb', line 4

def initialize(attrs = {})
  @attrs = attrs.dup
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



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

def method_missing(meth, *args)
  method_name = meth.to_s
  if method_name.end_with?('=')
    attr = method_name.chomp('=').to_sym
    @attrs[attr] = args.first        
  elsif method_name.end_with?('?')        
    attr = method_name.chomp('?').to_sym
    @attrs[attr] == true        
  elsif @attrs.has_key?(meth)        
    @attrs[meth]        
  else
    super meth, *args
  end
end

Instance Method Details

#shallow?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


8
9
10
# File 'lib/ews/model.rb', line 8

def shallow?
  raise NotImplementedError, "Each model must determine when it is shallow."
end