Class: Libis::Workflow::ActiveRecord::Workflow

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Base, Base::Workflow
Defined in:
lib/libis/workflow/activerecord/workflow.rb

Class Method Summary collapse

Methods included from Base

included, #to_hash, #to_s

Class Method Details

.from_hash(hash) ⇒ Object



23
24
25
26
27
28
# File 'lib/libis/workflow/activerecord/workflow.rb', line 23

def self.from_hash(hash)
  self.create_from_hash(hash, [:name]) do |item, cfg|
    item.configure(cfg.merge('name' => item.name))
    cfg.clear
  end
end

.load(file_or_hash) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/libis/workflow/activerecord/workflow.rb', line 30

def self.load(file_or_hash)
  config = Libis::Tools::ConfigFile.new
  config << file_or_hash
  return nil if config.empty?
  workflow = self.new
  workflow.configure(config.to_hash.key_symbols_to_strings(recursive: true))
  workflow
end