module TryingModels::ActsAsTryable::InstanceMethods

define instance methods, The Target included this module, so we get instance_methods in Target class

Public Class Methods

new(*args) click to toggle source

Example:

test = Article.new(name: "test_name", content: "test_content")

-> initialize object #<Article> and call super
-> send method [:_read_attribute, "name"]
-> send method [:_read_attribute, "content"]

#-> when initialize object, call all read_attribute base on model's columns name
-> read_attribute ["id"]
-> read_attribute ["name"]
-> read_attribute ["content"]
-> read_attribute ["created_at"]
-> read_attribute ["updated_at"]
Calls superclass method
# File lib/trying_models/acts_as_tryable.rb, line 36
def initialize(*args)
  # puts "initialize object #{self} and call super"
  super
end

Public Instance Methods

_read_attribute(*args) click to toggle source
Calls superclass method
# File lib/trying_models/acts_as_tryable.rb, line 51
def _read_attribute(*args)
  # puts "_read_attribute #{args}"
  super
end
method_missing(method, *args, &block) click to toggle source

override method missing from active_support lib purpose: not raise error when call any method name from instance object Example: test.anomyous_function_name

-> "Undefined Method" string return
# File lib/trying_models/acts_as_tryable.rb, line 62
def method_missing(method, *args, &block)
  "Undefined Method"
end
read_attribute(*args) click to toggle source
Calls superclass method
# File lib/trying_models/acts_as_tryable.rb, line 46
def read_attribute(*args)
  # puts "read_attribute #{args}"
  super
end
send(*args) click to toggle source
Calls superclass method
# File lib/trying_models/acts_as_tryable.rb, line 41
def send(*args)
  # puts "send method #{args}"
  super
end