Module: Rubyists::Linear::BaseModel::MethodMagic

Defined in:
lib/linear/models/base_model/method_magic.rb

Overview

Methods for Linear models.

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

rubocop:disable Metrics/AbcSize



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/linear/models/base_model/method_magic.rb', line 8

def self.included(base) # rubocop:disable Metrics/AbcSize
  base.instance_eval do
    base.base_fragment.__nodes.each do |node|
      sym = node.__name.to_sym
      define_method(sym) { updated_data[sym] } unless instance_methods.include? sym
      esym = :"#{sym}="
      next if instance_methods.include? esym

      define_method(esym) { |value| updated_data[sym] = value }
    end
  end
end