Module: Atatus::Fields

Overview

An interface for creating simple, value holding objects that correspond to object fields in the API.

Example:

class MyThing
  include Fields
  field :name
  field :address, default: 'There'
end

MyThing.new(name: 'AJ').to_h
  # => { name: 'AJ' }
MyThing.new().empty?
  # => true

Defined Under Namespace

Modules: ClassMethods, InstanceMethods Classes: Field

Class Method Summary collapse

Class Method Details

.included(cls) ⇒ Object



91
92
93
94
95
96
# File 'lib/atatus/fields.rb', line 91

def self.included(cls)
  cls.extend(ClassMethods)
  cls.include(InstanceMethods)

  cls.instance_variable_set(:@schema, {})
end