module Stackd::Concerns::TattrAccessor
Public Instance Methods
tattr?(key)
click to toggle source
# File lib/stackd/concerns/tattr_accessor.rb, line 43 def tattr? key self.class.instance_variable_get(:@_tattrs).has_key? key end
tattr_accessor(tattrs)
click to toggle source
# File lib/stackd/concerns/tattr_accessor.rb, line 13 def tattr_accessor tattrs tattrs.each do |tattr, type| attr_reader tattr @_tattrs[tattr] = type define_method :"#{tattr}=" do |value| unless value.nil? || self.class.tattr_type_match?(tattr, value) tattr_type = self.class.tattr_type tattr raise TypeMismatchError.new [ "tattr: #{tattr}", "tattr_type: #{tattr_type}", "value: #{value.inspect}" ].join ', ' end instance_variable_set :"@#{tattr}", value end end end
tattr_type(tattr)
click to toggle source
# File lib/stackd/concerns/tattr_accessor.rb, line 38 def tattr_type tattr @_tattrs[tattr] end
tattr_type_match?(tattr, value)
click to toggle source
# File lib/stackd/concerns/tattr_accessor.rb, line 34 def tattr_type_match? tattr, value value.is_a? tattr_type(tattr) end