Sha256: 672939de009312d2bdf3e19ac6e86e2b3296da3e568fa82e0813ee390ff58003

Contents?: true

Size: 597 Bytes

Versions: 18

Compression:

Stored size: 597 Bytes

Contents

# frozen_string_literal: true

module Basketball
  # Class-level methods that extend core Ruby attr_* methods.
  module ValueObjectDSL
    def all_value_keys
      @all_value_keys ||= ancestors.flat_map do |ancestor|
        if ancestor < Basketball::ValueObject
          ancestor.value_keys
        else
          []
        end
      end.uniq.sort
    end

    def all_sorted_value_keys
      all_value_keys.sort
    end

    def value_keys
      @value_keys ||= []
    end

    def value_reader(*keys)
      keys.each { |k| value_keys << k.to_sym }

      attr_reader(*keys)
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
basketball-0.0.27 lib/basketball/value_object_dsl.rb
basketball-0.0.26 lib/basketball/value_object_dsl.rb
basketball-0.0.25 lib/basketball/value_object_dsl.rb
basketball-0.0.24 lib/basketball/value_object_dsl.rb
basketball-0.0.23 lib/basketball/value_object_dsl.rb
basketball-0.0.22 lib/basketball/value_object_dsl.rb
basketball-0.0.21 lib/basketball/value_object_dsl.rb
basketball-0.0.20 lib/basketball/value_object_dsl.rb
basketball-0.0.19 lib/basketball/value_object_dsl.rb
basketball-0.0.18 lib/basketball/value_object_dsl.rb
basketball-0.0.17 lib/basketball/value_object_dsl.rb
basketball-0.0.16 lib/basketball/value_object_dsl.rb
basketball-0.0.15 lib/basketball/value_object_dsl.rb
basketball-0.0.14 lib/basketball/value_object_dsl.rb
basketball-0.0.13 lib/basketball/value_object_dsl.rb
basketball-0.0.12 lib/basketball/value_object_dsl.rb
basketball-0.0.11 lib/basketball/value_object_dsl.rb
basketball-0.0.10 lib/basketball/value_object_dsl.rb