Sha256: ea0d0450ac4d7e271abe80918152c67b138109e52431c2dfb0477cf73e9937a2
Contents?: true
Size: 1001 Bytes
Versions: 2
Compression:
Stored size: 1001 Bytes
Contents
# frozen_string_literal: true require "forwardable" module Attribool ## # Enumerable class that generates a list of attributes from a list of strings # or symbols. class AttributeList include Enumerable extend Forwardable ## # :method: each # Yield every entry in the list to a block. # # @param [block] &block # # @return [Enumerable] def_delegators :@entries, :each ## # Create an +AttributeList+ from a list of attribute names. # # @param [String, Symbol] *attribute_names # # @kwarg [nil, String, Symbol, Proc] method_name # # @return [AttributeList] def self.build(*attribute_names, method_name: nil) new(*attribute_names.map { |a| Attribool::Attribute.new(a, method_name) }) end ## # Construct the list. # # @param [String, Symbol] *attributes def initialize(*attributes) ValidatorService.call(:attribute_list, *attributes) @entries = attributes end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
attribool-2.0.5 | lib/attribool/attribute_list.rb |
attribool-2.0.4 | lib/attribool/attribute_list.rb |