2017-12-20 15:08:37 +00:00
|
|
|
class Sequencer
|
|
|
|
class Unit
|
|
|
|
module Common
|
|
|
|
module Provider
|
|
|
|
class Attribute < Sequencer::Unit::Base
|
|
|
|
|
|
|
|
def process
|
|
|
|
return if ignore?
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2017-12-20 15:08:37 +00:00
|
|
|
state.provide(attribute, value)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def attribute
|
|
|
|
@attribute ||= provides
|
|
|
|
end
|
|
|
|
|
|
|
|
def provides
|
|
|
|
provides_list = self.class.provides
|
|
|
|
raise "Only single provide attribute possible for class #{self.class.name}" if provides_list.size != 1
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2017-12-20 15:08:37 +00:00
|
|
|
provides_list.first
|
|
|
|
end
|
|
|
|
|
|
|
|
def value
|
|
|
|
@value ||= send(attribute)
|
|
|
|
end
|
|
|
|
|
|
|
|
def ignore?
|
|
|
|
# don't store nil values which are default anyway
|
|
|
|
value.nil?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|