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 Logger | |
def log str | |
p str | |
end | |
end | |
class Thing | |
extend Logger | |
def test_log |
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 Logger | |
def log str | |
p str | |
end | |
end | |
class Thing3 |
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 Logger | |
def log str | |
p str | |
end | |
end | |
class Thing2 | |
extend Logger | |
log "this does work from class" # => "this does work from 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
module Logger | |
def log str | |
p str | |
end | |
end | |
class Thing1 | |
include Logger | |
begin |
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
"string2".instance_eval { p self } # => "string2" | |
begin | |
"string2".class_eval { p self } | |
rescue Exception => e | |
p e # => #<NoMethodError: undefined method `class_eval' for "string2":String> | |
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
String.instance_eval do | |
def from_instance_eval | |
self | |
end | |
end | |
String.class_eval do | |
def from_class_eval | |
self | |
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 InvoicesController < ApplicationController | |
def index | |
respond_with id InvoicesDecorator.new(invoices, InvoiceDecorator) | |
end | |
end | |
class InvoicesDecorator < Draper::DecoratedEnumerableProxy | |
def method_regardless_of_invoices_empty_or_not | |
"yay" |
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
$.rails.showConfirmDialog = (link) -> | |
okButton = | |
type: 'btn btn-primary' | |
text: 'Ok' | |
click: (noty) -> $.rails.confirmed(link); noty.close() | |
cancelButton = | |
type: 'btn btn-danger' | |
text: 'Cancel' | |
click: (noty) -> noty.close() | |
noty |
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
$.rails.showConfirmDialog = (link) -> | |
html = """ | |
<div id="dialog-confirm" title="Are you sure you want to delete?"> | |
<p>These item will be permanently deleted and cannot be recovered. Are you sure?</p> | |
</div> | |
""" | |
$(html).dialog | |
resizable: false | |
modal: true | |
buttons: |
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
$.rails.showConfirmDialog = (link) -> | |
message = link.attr 'data-confirm' | |
html = """ | |
<div class="modal" id="confirmationDialog"> | |
<div class="modal-header"> | |
<a class="close" data-dismiss="modal">×</a> | |
<h3>#{message}</h3> | |
</div> | |
<div class="modal-body"> | |
<p>Are you sure you want to delete?</p> |