I hereby claim:
- I am mertguldur on github.
- I am mguldur (https://keybase.io/mguldur) on keybase.
- I have a public key ASBsh2JJjsKAD-JfPI292QIe8ySgesMI9LPmztj_cldbUwo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
module Interactors | |
class Base | |
MEMOIZATION_CACHE = {} | |
def self.memoize | |
method_name = :call | |
method = instance_method(method_name) | |
class_name = method.owner.name | |
define_method(method_name) do |*args| |
def flatten(array) | |
result = [] | |
array.each do |element| | |
if element.is_a?(Array) | |
result += flatten(element) | |
else | |
result << element | |
end | |
end | |
result |
class ProductsController < ApplicationController | |
def show | |
product = Product.find(params[:id]) | |
respond_to do |format| | |
format.html { render locals: { product: product } } | |
format.json { render json: product } | |
format.xml { render locals: { product: product } } | |
end | |
end |
### sort vs sort! - what's the difference between these, and what are their return values? | |
# sort returns a new structure but doesn't modify the given one | |
# where as sort! modifies the given structure and returns it | |
### splat - give an example of using splat to eat function args, another to call a function and provide the args with splat | |
def foo1(arg1, *args) | |
args | |
end |