Module: L43::OpenObject

Defined in:
lib/l43/open_object.rb,
lib/l43/open_object/behavior.rb,
lib/l43/open_object/initializer.rb

Defined Under Namespace

Modules: Behavior, Initializer

Constant Summary collapse

VERSION =
"0.2.1"

Instance Method Summary collapse

Instance Method Details

#attributes(*atts, **defaults, &blk) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/l43/open_object.rb', line 9

def attributes(*atts, **defaults, &blk)
  attr_reader(*atts)
  attr_reader(*defaults.keys)

  Initializer.define_initialize(self, atts, defaults, blk)
  include Behavior

  # define_method :update do |**kwds|
  #   if frozen?
  #     new_values = to_h.merge(**kwds)
  #     self.class.new(**new_values)
  #   else
  #     kwds.each do |k, v|
  #       instance_variable_set("@#{k}", v)
  #     end
  #     self
  #   end
  # end

  # define_method :update_attribute do |attribute, &blk|
  #   raise ArgumentError, "cannot update attribute #{attribute.inspect} without a block" unless blk
  #   update(attribute => blk.(to_h[attribute]))
  # end
end