lib/client_success/resources/base.rb
# Allows subclass resources to define the available
# attributes, so that there are corresponding getter
# and setter methods available.
#
# @param [Hash] attrs
#
# @example
#   class Foo < Base
#     declare_attrs(bar: :int, zoo: :string)
#     ...
#   end
#
Allows subclass resources to define the available
attributes, so that there are corresponding getter
and setter methods available.
Allows subclass resources to define the available attributes so that there are corresponding getter and setter methods available .
def declare_attrs(attrs)
          validate_types_for(attrs)
          @attributes = (@attributes || {}).merge(attrs)
          attrs.each_pair do |attr_name, _value_type|
            define_read_method(attr_name)
            define_write_method(attr_name)
          end
        end
def declare_attrs ( attrs ) validate_types_for ( attrs ) @attributes = ( @attributes || { } ) . merge ( attrs ) attrs . each_pair do | attr_name , _value_type | define_read_method ( attr_name ) define_write_method ( attr_name ) end end
Allows subclass resources to define the available
attributes, so that there are corresponding getter
and setter methods available.
Allows subclass resources to define the available attributes so that there are corresponding getter and setter methods available .
# Stored attributes for type conversion on save.
attrs
None
example
class Foo < Base declare_attrs(bar: :int, zoo: :string) ... end
class Foo < Base declare_attrs ( bar : : int zoo : : string ) ... end