Sha256: e291980ae07346483e7c372266d8618dd01e5c814521aeb0eb7c161399f27989
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true module Strict module Attributes class Dsl < BasicObject class << self def run(&) dsl = new dsl.instance_eval(&) ::Strict::Attributes::Configuration.new(attributes: dsl.__strict_dsl_internal_attributes.values) end end include ::Strict::Dsl::Coercible include ::Strict::Dsl::Validatable attr_reader :__strict_dsl_internal_attributes def initialize @__strict_dsl_internal_attributes = {} end def strict_attribute(*args, **kwargs) attribute = ::Strict::Attribute.make(*args, **kwargs) __strict_dsl_internal_attributes[attribute.name] = attribute nil end def method_missing(name, *args, **kwargs) if respond_to_missing?(name) strict_attribute(name, *args, **kwargs) else super end end def respond_to_missing?(method_name, _include_private = nil) first_letter = method_name.to_s.each_char.first first_letter.eql?(first_letter.downcase) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
strict-1.1.0 | lib/strict/attributes/dsl.rb |