Class: Taskr::Models::TaskAction

Inherits:
Base
  • Object
show all
Defined in:
lib/taskr/models.rb

Instance Method Summary collapse

Instance Method Details

#action_classObject



186
187
188
# File 'lib/taskr/models.rb', line 186

def action_class
  self[:action_class_name].constantize
end

#action_class=(class_name) ⇒ Object



178
179
180
181
182
183
184
# File 'lib/taskr/models.rb', line 178

def action_class=(class_name)
  if class_name.kind_of? Class
    self[:action_class_name] = class_name.to_s
  else
    self[:action_class_name] = class_name
  end
end

#descriptionObject



190
191
192
# File 'lib/taskr/models.rb', line 190

def description
  action_class.description
end

#to_sObject



209
210
211
# File 'lib/taskr/models.rb', line 209

def to_s
  "#{self.class.name.demodulize}(#{task_action})"
end

#to_xml(options = {}) ⇒ Object



194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/taskr/models.rb', line 194

def to_xml(options = {})
  options[:indent] ||= 2
  xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
  xml.instruct! unless options[:skip_instruct]
  xml.tag!('task-action', :type => self.class) do
    xml.tag!('id', {:type => 'integer'}, id)
    xml.tag!('action-class-name', action_class_name)
    xml.tag!('order', {:type => 'integer'}, order) unless order.blank?
    xml.tag!('task-id', {:type => 'integer'}, task_id)
    xml.tag!('action-parameters', {:type => 'array'}) do
      action_parameters.each {|ap| ap.to_xml(options)}
    end
  end
end