Sha256: 8c622252cda1c5dd3e35fab78945b2ea5fba787b5791f49f6cf35f5c677bb8cb

Contents?: true

Size: 705 Bytes

Versions: 5

Compression:

Stored size: 705 Bytes

Contents

module SoberSwag
  module Nodes
    ##
    # One attribute of an object.
    class Attribute < Base
      def initialize(key, required, value, meta = {})
        @key = key
        @required = required
        @value = value
        @meta = meta
      end

      def deconstruct
        [key, required, value, meta]
      end

      def deconstruct_keys
        { key: key, required: required, value: value, meta: meta }
      end

      attr_reader :key, :required, :value, :meta

      def map(&block)
        self.class.new(key, required, value.map(&block), meta)
      end

      def cata(&block)
        block.call(self.class.new(key, required, value.cata(&block), meta))
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sober_swag-0.19.0 lib/sober_swag/nodes/attribute.rb
sober_swag-0.18.0 lib/sober_swag/nodes/attribute.rb
sober_swag-0.17.0 lib/sober_swag/nodes/attribute.rb
sober_swag-0.16.0 lib/sober_swag/nodes/attribute.rb
sober_swag-0.15.0 lib/sober_swag/nodes/attribute.rb