Class: Shirinji::Bean

Inherits:
Object
  • Object
show all
Defined in:
lib/shirinji/bean.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, class_name: nil, value: nil, access:, construct: true, &block) ⇒ Bean

rubocop:disable Metrics/ParameterLists



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/shirinji/bean.rb', line 8

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

Instance Attribute Details

#accessObject (readonly)

Returns the value of attribute access.



5
6
7
# File 'lib/shirinji/bean.rb', line 5

def access
  @access
end

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/shirinji/bean.rb', line 5

def attributes
  @attributes
end

#class_nameObject (readonly)

Returns the value of attribute class_name.



5
6
7
# File 'lib/shirinji/bean.rb', line 5

def class_name
  @class_name
end

#constructObject (readonly)

Returns the value of attribute construct.



5
6
7
# File 'lib/shirinji/bean.rb', line 5

def construct
  @construct
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/shirinji/bean.rb', line 5

def name
  @name
end

#valueObject (readonly)

Returns the value of attribute value.



5
6
7
# File 'lib/shirinji/bean.rb', line 5

def value
  @value
end

Instance Method Details

#attr(name, ref: nil, value: nil) ⇒ Object

rubocop:enable Metrics/ParameterLists



24
25
26
# File 'lib/shirinji/bean.rb', line 24

def attr(name, ref: nil, value: nil)
  attributes[name] = Attribute.new(name, ref, value)
end