Module: ZohoHub::WithAttributes

Included in:
BaseRecord, Settings::Field, Settings::Module
Defined in:
lib/zoho_hub/with_attributes.rb

Overview

Allows adding attributes to a class, as attr_accessors that can then be listed from the class or an instance of that class.

Example

class User
  include ZohoHub::WithAttributes

  attributes :first_name, :last_name, :email
end

User.attributes # => [:first_name, :last_name, :email]
User.new.attributes # => [:first_name, :last_name, :email]

user = User.new
user.first_name = 'Ricardo'
user.last_name = 'Otero'
user.first_name # => "Ricardo"

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



23
24
25
# File 'lib/zoho_hub/with_attributes.rb', line 23

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#attributesObject

Returns the list of attributes defined for the instance class.



52
53
54
# File 'lib/zoho_hub/with_attributes.rb', line 52

def attributes
  self.class.attributes
end