Class: Dgrid::API::Incident
- Inherits:
-
NamedEntity
- Object
- Entity
- NamedEntity
- Dgrid::API::Incident
- Defined in:
- lib/dgrid/api/incident.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#time ⇒ Object
Returns the value of attribute time.
Attributes inherited from NamedEntity
Attributes inherited from Entity
#description, #id, #workspaces
Class Method Summary collapse
Instance Method Summary collapse
- #add_organization(organization) ⇒ Object
- #add_person(person) ⇒ Object
- #add_place(place) ⇒ Object
- #add_time_to_hash(h, t, prefix) ⇒ Object
-
#initialize(options) ⇒ Incident
constructor
A new instance of Incident.
- #to_hash ⇒ Object
Methods inherited from Entity
#add_entity, #add_workspace, #attach, #connection, #first_workspace, #in_workspace?, #link_to, #new_record?, singular, #type, type
Methods included from SetMembersFromHash
#change_string_keys_to_symbol_keys, #set_members_from_hash, #split_hash
Methods included from Dgrid::ArgumentValidation
Constructor Details
#initialize(options) ⇒ Incident
Returns a new instance of Incident.
17 18 19 20 21 22 |
# File 'lib/dgrid/api/incident.rb', line 17 def initialize() parent_opts, my_opts = split_hash(,[:name, :description]) super(parent_opts) member_opts = fix_time_opts(my_opts) set_members_from_hash(member_opts) end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
4 5 6 |
# File 'lib/dgrid/api/incident.rb', line 4 def body @body end |
#end_time ⇒ Object
Returns the value of attribute end_time.
4 5 6 |
# File 'lib/dgrid/api/incident.rb', line 4 def end_time @end_time end |
#time ⇒ Object
Returns the value of attribute time.
4 5 6 |
# File 'lib/dgrid/api/incident.rb', line 4 def time @time end |
Class Method Details
.db_fields ⇒ Object
24 25 26 |
# File 'lib/dgrid/api/incident.rb', line 24 def self.db_fields %w(id name body time end_time) end |
.pluralized ⇒ Object
34 35 36 |
# File 'lib/dgrid/api/incident.rb', line 34 def self.pluralized 'incidents' end |
Instance Method Details
#add_organization(organization) ⇒ Object
58 59 60 |
# File 'lib/dgrid/api/incident.rb', line 58 def add_organization(organization) add_entity(organization) end |
#add_person(person) ⇒ Object
48 49 50 |
# File 'lib/dgrid/api/incident.rb', line 48 def add_person(person) add_entity(person) end |
#add_place(place) ⇒ Object
53 54 55 |
# File 'lib/dgrid/api/incident.rb', line 53 def add_place(place) add_entity(place) end |
#add_time_to_hash(h, t, prefix) ⇒ Object
28 29 30 31 32 |
# File 'lib/dgrid/api/incident.rb', line 28 def add_time_to_hash(h, t,prefix) h["#{prefix}_time".to_sym] = t.strftime("%H:%M") h["#{prefix}_date".to_sym] = t.strftime("%Y-%m-%d") h end |
#to_hash ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/dgrid/api/incident.rb', line 38 def to_hash h = { :name => name, :body => body } add_time_to_hash(h,time,'time') unless time.nil? add_time_to_hash(h,end_time,'end_time') unless end_time.nil? h end |