Module: Artery::Model::ClassMethods

Defined in:
lib/artery/model.rb

Instance Method Summary collapse

Instance Method Details

#artery_default_representation(&blk) ⇒ Object



57
58
59
# File 'lib/artery/model.rb', line 57

def artery_default_representation(&blk)
  artery_representation :_default, &blk
end

#artery_model_nameObject



35
36
37
# File 'lib/artery/model.rb', line 35

def artery_model_name
  artery[:name]
end

#artery_model_name_pluralObject



39
40
41
# File 'lib/artery/model.rb', line 39

def artery_model_name_plural
  artery_model_name.to_s.pluralize.to_sym
end

#artery_representation(*services, &blk) ⇒ Object



51
52
53
54
55
# File 'lib/artery/model.rb', line 51

def artery_representation(*services, &blk)
  services.each do |service_name|
    artery[:representations][service_name.to_sym] = blk
  end
end

#artery_scope(name, lmbd) ⇒ Object



69
70
71
# File 'lib/artery/model.rb', line 69

def artery_scope(name, lmbd)
  scope :"artery_#{name}", lmbd
end

#artery_source_model?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/artery/model.rb', line 43

def artery_source_model?
  artery[:source]
end

#artery_uuid_attributeObject



47
48
49
# File 'lib/artery/model.rb', line 47

def artery_uuid_attribute
  artery[:uuid_attribute]
end

#artery_version(version = nil) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/artery/model.rb', line 61

def artery_version(version = nil)
  if version
    artery[:version] = version
  else
    artery[:version] || 'v1'
  end
end

#inherited(sub_class) ⇒ Object

Always clone artery configuration in subclass from parent class



30
31
32
33
# File 'lib/artery/model.rb', line 30

def inherited(sub_class)
  sub_class.artery = artery.dup
  super
end