Module: AR2DTO::HasDTO::ClassMethods
- Defined in:
- lib/ar2dto/has_dto.rb
Instance Method Summary collapse
- #ar2dto ⇒ Object
-
#has_dto(options = {}) ⇒ Object
Declare this in your model to expose the DTO helpers.
- #to_dto(options = {}) ⇒ Object
Instance Method Details
#ar2dto ⇒ Object
31 32 33 |
# File 'lib/ar2dto/has_dto.rb', line 31 def ar2dto @ar2dto ||= AR2DTO::ModelConfig.new(self) end |
#has_dto(options = {}) ⇒ Object
Declare this in your model to expose the DTO helpers.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ar2dto/has_dto.rb', line 14 def has_dto( = {}) include ::AR2DTO::HasDTO::InstanceMethods ar2dto.setup_config() begin ar2dto.namespaced_class_name.constantize rescue NameError ar2dto.namespace.const_set(ar2dto.class_name, AR2DTO::DTO[self]) end end |
#to_dto(options = {}) ⇒ Object
26 27 28 |
# File 'lib/ar2dto/has_dto.rb', line 26 def to_dto( = {}) all.map { |record| record.to_dto() } end |