Class: Goz::Event

Inherits:
Sequel::Model
  • Object
show all
Defined in:
lib/goz/event.rb

Overview

Goz::Event - Goz event

Author

blair christensen. <[email protected]>

Homepage

github.com/blairc/goz/

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*params) {|_self| ... } ⇒ Event

Initialize new (non-persistent) Goz::Event object

Yields:

  • (_self)

Yield Parameters:

  • _self (Goz::Event)

    the object that the method was called on



33
34
35
36
37
# File 'lib/goz/event.rb', line 33

def initialize(*params)
  super
  yield self if block_given?
  self
end

Class Method Details

.admin_add(group, user) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/goz/event.rb', line 39

def self.admin_add(group, user)
  self.create :event_type    => Goz::EventType::ADMIN_ADD,
              :group         => group,
              :group_id      => group.id,
              :user          => user,
              :user_id       => user.id
end

.admin_remove(group, user) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/goz/event.rb', line 47

def self.admin_remove(group, user)
  self.create :event_type    => Goz::EventType::ADMIN_REMOVE,
              :group         => group,
              :group_id      => group.id,
              :user          => user,
              :user_id       => user.id
end

.group_add(group) ⇒ Object



55
56
57
58
59
# File 'lib/goz/event.rb', line 55

def self.group_add(group)
  self.create :event_type    => Goz::EventType::GROUP_ADD,
              :group         => group,
              :group_id      => group.id
end

.group_remove(group) ⇒ Object



61
62
63
64
65
# File 'lib/goz/event.rb', line 61

def self.group_remove(group)
  self.create :event_type    => Goz::EventType::GROUP_REMOVE,
              :group         => group,
              :group_id      => group.id
end

.group_service_add(group, service) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/goz/event.rb', line 73

def self.group_service_add(group, service)
  self.create :event_type    => Goz::EventType::GROUP_SERVICE_ADD,
              :group         => group,
              :group_id      => group.id,
              :service       => service,
              :service_id    => service.id
end

.group_service_remove(group, service) ⇒ Object



81
82
83
84
85
86
87
# File 'lib/goz/event.rb', line 81

def self.group_service_remove(group, service)
  self.create :event_type    => Goz::EventType::GROUP_SERVICE_REMOVE,
              :group         => group,
              :group_id      => group.id,
              :service       => service,
              :service_id    => service.id
end

.group_service_sync(group, service) ⇒ Object



89
90
91
92
93
94
95
# File 'lib/goz/event.rb', line 89

def self.group_service_sync(group, service)
  self.create :event_type    => Goz::EventType::GROUP_SERVICE_SYNC,
              :group         => group,
              :group_id      => group.id,
              :service       => service,
              :service_id    => service.id
end

.group_sync(group) ⇒ Object



67
68
69
70
71
# File 'lib/goz/event.rb', line 67

def self.group_sync(group)
  self.create :event_type    => Goz::EventType::GROUP_SYNC,
              :group         => group,
              :group_id      => group.id
end

.member_add(group, user) ⇒ Object



97
98
99
100
101
102
103
# File 'lib/goz/event.rb', line 97

def self.member_add(group, user)
  self.create :event_type    => Goz::EventType::MEMBER_ADD,
              :group         => group,
              :group_id      => group.id,
              :user          => user,
              :user_id       => user.id
end

.member_remove(group, user) ⇒ Object



105
106
107
108
109
110
111
# File 'lib/goz/event.rb', line 105

def self.member_remove(group, user)
  self.create :event_type    => Goz::EventType::MEMBER_REMOVE,
              :group         => group,
              :group_id      => group.id,
              :user          => user,
              :user_id       => user.id
end

.service_add(service) ⇒ Object



113
114
115
116
117
# File 'lib/goz/event.rb', line 113

def self.service_add(service)
  self.create :event_type    => Goz::EventType::SERVICE_ADD,
              :service       => service,
              :service_id    => service.id
end

.service_remove(service) ⇒ Object



119
120
121
122
123
# File 'lib/goz/event.rb', line 119

def self.service_remove(service)
  self.create :event_type    => Goz::EventType::SERVICE_REMOVE,
              :service       => service,
              :service_id    => service.id
end

.service_sync(service) ⇒ Object



125
126
127
128
129
# File 'lib/goz/event.rb', line 125

def self.service_sync(service)
  self.create :event_type    => Goz::EventType::SERVICE_SYNC,
              :service       => service,
              :service_id    => service.id
end

.user_add(user) ⇒ Object



131
132
133
134
135
# File 'lib/goz/event.rb', line 131

def self.user_add(user)
  self.create :event_type    => Goz::EventType::USER_ADD,
              :user          => user,
              :user_id       => user.id
end

.user_remove(user) ⇒ Object



137
138
139
140
141
# File 'lib/goz/event.rb', line 137

def self.user_remove(user)
  self.create :event_type    => Goz::EventType::USER_REMOVE,
              :user          => user,
              :user_id       => user.id
end

.user_sync(user) ⇒ Object



143
144
145
146
147
# File 'lib/goz/event.rb', line 143

def self.user_sync(user)
  self.create :event_type    => Goz::EventType::USER_SYNC,
              :user          => user,
              :user_id       => user.id
end

Instance Method Details

#validateObject

Perform model valiations.



153
154
155
156
157
158
# File 'lib/goz/event.rb', line 153

def validate
  super
  validates_presence  :event_type
  validates_includes  Goz::EventType::TYPES, :event_type
  validates_type      Integer, [ :group_id, :service_id, :user_id ]
end