Sha256: ae18164b6f39459f0b26b41cddc4cdf63aa1aabd9a97cf6ca44dbbb0d339e0e5
Contents?: true
Size: 890 Bytes
Versions: 1
Compression:
Stored size: 890 Bytes
Contents
# frozen_string_literal: true module Shirinji class Bean attr_reader :name, :class_name, :value, :access, :attributes, :construct def initialize( name, class_name: nil, value: nil, access:, construct: true, &block ) check_params!(class_name, value) @name = name @class_name = class_name @value = value @access = access @attributes = {} @construct = construct instance_eval(&block) if block end def attr(name, ref:) attributes[name] = Attribute.new(name, ref) end private def check_params!(class_name, value) msg = if class_name && value 'you can use either `class_name` or `value` but not both' elsif !class_name && !value 'you must pass either `class_name` or `value`' end raise ArgumentError, msg if msg end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shirinji-0.0.3 | lib/shirinji/bean.rb |