Sha256: cd789548f01d15d35c6888389d8bc76896f9329159e02ee4e7591b4c98039772

Contents?: true

Size: 405 Bytes

Versions: 1

Compression:

Stored size: 405 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 serialize(target)
      case @method
      when Symbol, String
        target.public_send(@method)
      when Proc
        @method.call(target)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alba-0.1.0 lib/alba/attribute.rb