Class: Dgrid::API::Keyword

Inherits:
NamedEntity show all
Defined in:
lib/dgrid/api/keyword.rb

Instance Attribute Summary collapse

Attributes inherited from NamedEntity

#name

Attributes inherited from Entity

#description, #id, #workspaces

Class Method Summary collapse

Instance Method Summary collapse

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

included

Constructor Details

#initialize(options) ⇒ Keyword

Returns a new instance of Keyword.



11
12
13
14
15
16
# File 'lib/dgrid/api/keyword.rb', line 11

def initialize(options)
  parent_opts, my_opts = split_hash(options,[:id, :name])
	super(parent_opts)
  set_members_from_hash(my_opts)

end

Instance Attribute Details

#synonymsObject

Returns the value of attribute synonyms.



4
5
6
# File 'lib/dgrid/api/keyword.rb', line 4

def synonyms
  @synonyms
end

#triggers_alertObject

Returns the value of attribute triggers_alert.



5
6
7
# File 'lib/dgrid/api/keyword.rb', line 5

def triggers_alert
  @triggers_alert
end

Class Method Details

.db_fieldsObject



18
19
20
# File 'lib/dgrid/api/keyword.rb', line 18

def self.db_fields
  %w(id name synonyms triggers_alert)
end

.pluralizedObject



31
32
33
# File 'lib/dgrid/api/keyword.rb', line 31

def self.pluralized
  'keywords'
end

Instance Method Details

#to_hashObject



22
23
24
25
26
27
28
29
# File 'lib/dgrid/api/keyword.rb', line 22

def to_hash
  h = super
  h.delete(:description)
  h.merge!( { :synonyms => synonyms,
              :triggers_alert => triggers_alert
            })
  h
end