Module: Libis::Workflow::ActiveRecord::Base

Included in:
Job, Status, WorkItem, Workflow
Defined in:
lib/libis/workflow/activerecord/base.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/libis/workflow/activerecord/base.rb', line 10

def self.included(klass)
  klass.extend(ClassMethods)

  # def [](key)
  #   self.send(key.to_sym)
  # end
  #
  # def []=(key,value)
  #   self.send(key.to_s + '=', value)
  # end
end

Instance Method Details

#to_hashObject



45
46
47
48
49
50
# File 'lib/libis/workflow/activerecord/base.rb', line 45

def to_hash
  result = self.attributes.reject { |k, v| v.blank? || volatile_attributes.include?(k) }
  result = result.to_yaml
  # noinspection RubyResolve
  YAML.load(result)
end

#to_sObject



52
53
54
# File 'lib/libis/workflow/activerecord/base.rb', line 52

def to_s
  self.name || "#{self.class.name}_#{self.id}"
end