Created
August 7, 2018 10:17
-
-
Save hadrienblanc/85ce087428dc19fb31a5542648b9c1b0 to your computer and use it in GitHub Desktop.
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 Miouable | |
def miouw | |
puts 'miouw !' | |
end | |
end | |
class CatWithExtend | |
extend Miouable | |
end | |
cat = CatWithExtend.new | |
cat.miouw | |
# NoMethodError | |
# undefined method miouw | |
CatWithExtend.miouw | |
# miouw ! | |
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 Miouable | |
def miouw | |
puts 'miouw !' | |
end | |
end | |
class Cat | |
include Miouable | |
end | |
cat = Cat.new | |
cat.miouw | |
# miouw ! | |
Cat.miouw | |
# NoMethodError | |
# undefined method miouw for Cat:Class | |
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
class Pokemon < ApplicationRecord | |
scope :active, where(active: true) | |
scope :red, where(color: 'red') | |
scope :with_evolution, where.not(next_evolution: nil) | |
scope :not_savage, where.not(owner_id: 0) | |
scope :lvl, -> (level) { where(level: level) } | |
def self.all_active_red_with_evolution_and_not_savage | |
active.red.with_evolution.not_savage | |
end | |
def self.all_red_with_evolution | |
red.with_evolution | |
end | |
def all_red_with_evolution_at_level_max | |
red.with_evolution.lvl(100) | |
end | |
end |
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
class Pokemon < ApplicationRecord | |
def self.all_active_red_with_evolution_and_not_savage | |
where(active: true).where(color: 'red').where.not(next_evolution: nil).where.not(owner_id: 0) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment