Class: AR2DTO::ModelConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/ar2dto/model_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ ModelConfig

Returns a new instance of ModelConfig.



7
8
9
# File 'lib/ar2dto/model_config.rb', line 7

def initialize(model)
  @model = model
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



5
6
7
# File 'lib/ar2dto/model_config.rb', line 5

def model
  @model
end

#model_configObject (readonly)

Returns the value of attribute model_config.



5
6
7
# File 'lib/ar2dto/model_config.rb', line 5

def model_config
  @model_config
end

Instance Method Details

#active_model_complianceObject



15
16
17
# File 'lib/ar2dto/model_config.rb', line 15

def active_model_compliance
  @active_model_compliance ||= global_config.active_model_compliance
end

#class_nameObject



23
24
25
# File 'lib/ar2dto/model_config.rb', line 23

def class_name
  @class_name ||= namespaced_class_name.split("::").last
end

#exceptObject



19
20
21
# File 'lib/ar2dto/model_config.rb', line 19

def except
  @except ||= Array(global_config.except) | Array(model_config[:except])
end

#namespaceObject



27
28
29
# File 'lib/ar2dto/model_config.rb', line 27

def namespace
  @namespace ||= namespaced_class_name.deconstantize.presence&.constantize || Object
end

#namespaced_class_nameObject



31
32
33
# File 'lib/ar2dto/model_config.rb', line 31

def namespaced_class_name
  @namespaced_class_name ||= model_config[:class_name] || model_name_replaced_suffix
end

#setup_config(model_config) ⇒ Object



11
12
13
# File 'lib/ar2dto/model_config.rb', line 11

def setup_config(model_config)
  @model_config ||= model_config
end