2017-09-01 11:59:12 +00:00
|
|
|
class Sequencer
|
|
|
|
class Unit
|
|
|
|
module Common
|
|
|
|
module Mixin
|
|
|
|
module DynamicAttribute
|
|
|
|
|
|
|
|
def self.included(base)
|
|
|
|
|
|
|
|
class << base
|
|
|
|
|
|
|
|
def inherited(base)
|
|
|
|
base.extend(Forwardable)
|
|
|
|
base.instance_delegate [:attribute] => base
|
|
|
|
end
|
|
|
|
|
|
|
|
def attribute
|
|
|
|
@attribute ||= begin
|
|
|
|
if uses.size != 1
|
|
|
|
raise "DynamicAttribute classes can use exactly one attribute. Found #{uses.size}."
|
|
|
|
end
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2017-09-01 11:59:12 +00:00
|
|
|
uses.first
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def attribute_value
|
|
|
|
@attribute_value ||= state.use(attribute)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|