Module: Ryext::Models::Model

Included in:
Category, Customer, Location, Offer, Optimization, OptimizationTask, Order, PublisherSuggestion, Scan, Status, Subscription
Defined in:
lib/ryext/models/model.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(model) ⇒ Object



4
5
6
7
8
9
# File 'lib/ryext/models/model.rb', line 4

def self.included(model)
  model.class_eval do
    attr_accessor *model::YEXT_ATTRIBUTES.keys
    attr_accessor :account, :attributes
  end
end

Instance Method Details

#build(attributes) ⇒ Object



18
19
20
21
22
# File 'lib/ryext/models/model.rb', line 18

def build(attributes)
  self.class::YEXT_ATTRIBUTES.each do |key, string_key|
    self.send("#{key}=", attributes.delete(string_key) || attributes.delete(key))
  end
end

#initialize(attributes, account) ⇒ Object



11
12
13
14
15
16
# File 'lib/ryext/models/model.rb', line 11

def initialize(attributes, )
  self. = 
  self.attributes = attributes

  build(attributes)
end

#instance_klassObject



24
25
26
# File 'lib/ryext/models/model.rb', line 24

def instance_klass
  @instance_klass || OpenStruct
end