Sha256: fbd286b893c1b796bbebf2019dafd74de3f1798b567717bc25a11cf0ad999025
Contents?: true
Size: 1002 Bytes
Versions: 4
Compression:
Stored size: 1002 Bytes
Contents
# frozen_string_literal: true module Shirinji class Bean attr_reader :name, :class_name, :value, :access, :attributes, :construct # rubocop:disable Metrics/ParameterLists 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 # rubocop:enable Metrics/ParameterLists def attr(name, ref: nil, value: nil) attributes[name] = Attribute.new(name, ref, value) 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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
shirinji-0.0.8 | lib/shirinji/bean.rb |
shirinji-0.0.7 | lib/shirinji/bean.rb |
shirinji-0.0.6 | lib/shirinji/bean.rb |
shirinji-0.0.5 | lib/shirinji/bean.rb |