lib/museek_bindings/message/base.rb
# Define a getter for given attribute.
#  also defines a getter with question mark for boolean attribute
#
# @param name [Symbol] the name of attribute
# @param type [Symbol] the type of attribute
# @param default [String, Integer, Boolean] the default value for attribute.
#
# @since 0.0.1
# @api private
Define a getter for given attribute.
also defines a getter with question mark for boolean attribute
Define a getter for given attribute . also defines a getter with question mark for boolean attribute
def define_getter(name, type, default = nil)
      getter = ->() { instance_variable_get("@#{name}") || default }
      define_method("#{name}?", &getter) if type == :boolean
      define_method(name, &getter)
    end
def define_getter ( name , type , default = nil ) getter = -> ( ) { instance_variable_get ( "@#{name}" ) || default } define_method ( "#{name}?" , & getter ) if type == :boolean define_method ( name , & getter ) end
Define a getter for given attribute.
Define a getter for given attribute .
name
the name of attribute
the name of attribute
type
the type of attribute
the type of attribute
default
the default value for attribute.
the default value for attribute .
since
None
api
None