Class: EWS::Model

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

Direct Known Subclasses

Attachment, Folder, Message

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Model

Returns a new instance of Model.



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

def initialize(attrs = {})
  @attrs = attrs.dup
  @service = EWS::Service
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



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

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 Attribute Details

#serviceObject

Returns the value of attribute service.



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

def service
  @service
end

Instance Method Details

#shallow?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


11
12
13
# File 'lib/ews/model.rb', line 11

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