View blocks_procs_lambdas.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Difference between blocks, procs and lambdas. | |
Blocks are not objects and can't be manipulates as objects. With procs and lambdas is possible to | |
create objects that represents a block. | |
Procs and lambdas have the 'call' method, that executes the block code associated in their creation. | |
A proc behaves like a block, different of lambdas that behaves like a method. For that reason, | |
lambdas need to receive the exact number of parameters defined in your declaration. |
View init_attributes.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module InitAttributes | |
def self.included(base) | |
base.send(:include, InstanceMethods) | |
base.extend(ClassMethods) | |
end | |
module InstanceMethods | |
def initialize(attributes) | |
init_instance_variables(self.class.accessor_attributes, attributes) | |
init_instance_variables(self.class.reader_attributes, attributes) |
View gist:2bde80805ec17a46b13eac44d9e4ccfb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am prodis on github. | |
* I am prodis (https://keybase.io/prodis) on keybase. | |
* I have a public key ASBYWVy_Ip4Ln4bB3NQeUXJeiZScRB3HwNvoJh-_bbiT3Ao | |
To claim this, I am signing this object: |
OlderNewer