Class: OTRS::GeneralCatalog
- Defined in:
- lib/otrs_connector/otrs/general_catalog.rb
Instance Attribute Summary collapse
-
#change_by ⇒ Object
Returns the value of attribute change_by.
-
#change_time ⇒ Object
Returns the value of attribute change_time.
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#create_by ⇒ Object
Returns the value of attribute create_by.
-
#create_time ⇒ Object
Returns the value of attribute create_time.
-
#item_id ⇒ Object
Returns the value of attribute item_id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#valid_id ⇒ Object
Returns the value of attribute valid_id.
Class Method Summary collapse
- .class_list ⇒ Object
- .find(id) ⇒ Object
- .item_list(name) ⇒ Object
- .item_list_fast(name) ⇒ Object
- .set_accessor(key) ⇒ Object
Instance Method Summary collapse
- #attributes ⇒ Object
-
#initialize(attributes = {}) ⇒ GeneralCatalog
constructor
A new instance of GeneralCatalog.
- #item_list ⇒ Object
- #persisted? ⇒ Boolean
- #save ⇒ Object
Methods inherited from OTRS
api_url, api_url=, #connect, connect, object_preprocessor, password, password=, user, user=
Constructor Details
#initialize(attributes = {}) ⇒ GeneralCatalog
Returns a new instance of GeneralCatalog.
11 12 13 14 15 16 |
# File 'lib/otrs_connector/otrs/general_catalog.rb', line 11 def initialize(attributes = {}) attributes.each do |name, value| self.class.set_accessor(name.to_s.underscore) send("#{name.to_s.underscore.to_sym}=", value) end end |
Instance Attribute Details
#change_by ⇒ Object
Returns the value of attribute change_by.
2 3 4 |
# File 'lib/otrs_connector/otrs/general_catalog.rb', line 2 def change_by @change_by end |
#change_time ⇒ Object
Returns the value of attribute change_time.
2 3 4 |
# File 'lib/otrs_connector/otrs/general_catalog.rb', line 2 def change_time @change_time end |
#comment ⇒ Object
Returns the value of attribute comment.
2 3 4 |
# File 'lib/otrs_connector/otrs/general_catalog.rb', line 2 def comment @comment end |
#create_by ⇒ Object
Returns the value of attribute create_by.
2 3 4 |
# File 'lib/otrs_connector/otrs/general_catalog.rb', line 2 def create_by @create_by end |
#create_time ⇒ Object
Returns the value of attribute create_time.
2 3 4 |
# File 'lib/otrs_connector/otrs/general_catalog.rb', line 2 def create_time @create_time end |
#item_id ⇒ Object
Returns the value of attribute item_id.
2 3 4 |
# File 'lib/otrs_connector/otrs/general_catalog.rb', line 2 def item_id @item_id end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/otrs_connector/otrs/general_catalog.rb', line 2 def name @name end |
#valid_id ⇒ Object
Returns the value of attribute valid_id.
2 3 4 |
# File 'lib/otrs_connector/otrs/general_catalog.rb', line 2 def valid_id @valid_id end |
Class Method Details
.class_list ⇒ Object
71 72 73 74 75 |
# File 'lib/otrs_connector/otrs/general_catalog.rb', line 71 def self.class_list data = { } params = { :object => 'GeneralCatalogObject', :method => 'ClassList', :data => data } a = connect(params).first end |
.find(id) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/otrs_connector/otrs/general_catalog.rb', line 30 def self.find(id) data = { 'ItemID' => id } params = { :object => 'GeneralCatalogObject', :method => 'ItemGet', :data => data } a = connect(params) unless a.first.nil? a = a.first.except('Class') ## Class field is causing issues in Rails end self.new(a) end |
.item_list(name) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/otrs_connector/otrs/general_catalog.rb', line 40 def self.item_list(name) data = { :Class => name, :Valid => 1 } params = { :object => 'GeneralCatalogObject', :method => 'ItemList', :data => data } a = connect(params).first #b = [] #unless a.nil? # a.each do |key,value| # b << self.find(key) # end # self.superclass::Relation.new(b) #end end |
.item_list_fast(name) ⇒ Object
53 54 55 56 57 |
# File 'lib/otrs_connector/otrs/general_catalog.rb', line 53 def self.item_list_fast(name) data = { :Class => name, :Valid => 1 } params = { :object => 'GeneralCatalogObject', :method => 'ItemList', :data => data } a = connect(params).first end |
.set_accessor(key) ⇒ Object
3 4 5 |
# File 'lib/otrs_connector/otrs/general_catalog.rb', line 3 def self.set_accessor(key) attr_accessor key.to_sym end |
Instance Method Details
#attributes ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/otrs_connector/otrs/general_catalog.rb', line 18 def attributes attributes = {} self.instance_variables.each do |v| attributes[v.to_s.gsub('@','').to_sym] = self.instance_variable_get(v) end attributes end |
#item_list ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/otrs_connector/otrs/general_catalog.rb', line 59 def item_list data = { :Class => self.name } params = { :object => 'GeneralCatalogObject', :method => 'ItemList', :data => data } a = connect(params) unless a.nil? then a = a.first end b = [] a.each do |key,value| b << self.find(key) end self.superclass::Relation.new(b) end |
#persisted? ⇒ Boolean
7 8 9 |
# File 'lib/otrs_connector/otrs/general_catalog.rb', line 7 def persisted? false end |
#save ⇒ Object
26 27 28 |
# File 'lib/otrs_connector/otrs/general_catalog.rb', line 26 def save self.create(self.attributes) end |