Sha256: be2030ac605c4c62a04d68a763d47ffcf00fc9b33700c21b06b3054233102bbf
Contents?: true
Size: 458 Bytes
Versions: 7
Compression:
Stored size: 458 Bytes
Contents
module Alba # This class represents an attribute, which is serialized # by either sending message or calling a Proc. class Attribute def initialize(name:, method:) @name = name @method = method end def to_hash(target) case @method when Symbol, String target.public_send(@method) when Proc @method.arity.zero? ? target.instance_exec(&@method) : @method.call(target) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems