Module: Artery::Model

Defined in:
lib/artery/model.rb,
lib/artery/model/callbacks.rb,
lib/artery/model/subscriptions.rb

Defined Under Namespace

Modules: Callbacks, ClassMethods, InstanceMethods, Subscriptions

Instance Method Summary collapse

Instance Method Details

#artery_model(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/artery/model.rb', line 8

def artery_model(options = {})
  extend ClassMethods
  include InstanceMethods

  options[:name] ||= to_s.demodulize.underscore.to_sym
  options[:source] = false if options[:source].nil?
  options[:uuid_attribute] = :uuid if options[:uuid_attribute].nil?

  class_attribute :artery, instance_writer: false

  self.artery = options.merge(representations: {
                                _default: proc { attributes }
                              })

  include Subscriptions
  include Callbacks if artery_source_model?

  artery_scope :all, -> { all }
end