module BN::Helpers::HasAttributes

Adds the ‘update_attributes` method and `attribute` class method.

Public Class Methods

included(base) click to toggle source
# File lib/bn/helpers/has_attributes.rb, line 21
def included(base)
  base.extend(ClassMethods)
end
new(attributes={}) click to toggle source

Initialize this object by optionally updating attributes with a Hash.

@param [#to_h] attributes Attributes to set after initializing.

# File lib/bn/helpers/has_attributes.rb, line 29
def initialize(attributes={})
  update_attributes(attributes)
end

Public Instance Methods

update_attributes(attributes={}) click to toggle source

Update any attributes on this object.

@param [#to_h] attributes @return [Hash] The attributes.

# File lib/bn/helpers/has_attributes.rb, line 37
def update_attributes(attributes={})
  attributes = attributes.to_h
  attributes.each { |name, value| send("#{name}=", value) }

  attributes
end