It's common in Ruby to see some code setup a Struct like this:
class Specialized < Struct.new(:whatever)
# ... define custom methods here...
end| [1] pry(main)> Class.new.respond_to?(:define_method) | |
| => false | |
| [2] pry(main)> Module.new.respond_to?(:define_method) | |
| => false | |
| [3] pry(main)> Class.new.send(:define_method, :yup) {} | |
| => #<Proc:0x00000100a08cb8@(pry):3 (lambda)> | |
| [4] pry(main)> Module.new.send(:define_method, :yup) {} | |
| => #<Proc:0x00000100d8f468@(pry):4 (lambda)> |
| [user] | |
| name = Ben Hyrman | |
| email = [email protected] | |
| [core] | |
| autocrlf = true | |
| editor = vim | |
| excludesfile = C:\\Users\\Ben\\Documents\\gitignore_global.txt | |
| [credential] | |
| helper = !~/AppData/Roaming/GitCredStore/git-credential-winstore | |
| [merge] |
| define(function (require) { | |
| var module; | |
| // Setup temporary Google Analytics objects. | |
| window.GoogleAnalyticsObject = "ga"; | |
| window.ga = function () { (window.ga.q = window.ga.q || []).push(arguments); }; | |
| window.ga.l = 1 * new Date(); | |
| // Immediately add a pageview event to the queue. |
| # So, this is pretty horrible. If we just encode using btoa, any UTF-8 chars cause an error. | |
| # If we use either of the workarounds on MDN[1], the £ sign is encoded wrong. I suspect | |
| # Excel totally sucking at encodings is the reason why. So, the workaround is, to use | |
| # the MDN workaround on chars with values > 255, and allow chars 0-255 to be encoded | |
| # as is with btoa. Note that if you use either of the workarounds on MDN, chars | |
| # 128-255 will be encoded as UTF-8, which includeds the £ sign. This will cause excel | |
| # to choke on these chars. Excel will still choke on chars > 255, but at least the £ | |
| # sign works now... | |
| # [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Base64_encoding_and_decoding |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src="http://code.jquery.com/jquery.js"></script> | |
| <script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.js"></script> | |
| <script src="http://builds.emberjs.com/ember-latest.js"></script> | |
| <meta charset=utf-8 /> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> |
| (function (global) { | |
| "use strict"; | |
| function empty(obj) { | |
| var key; | |
| for (key in obj) if (obj.hasOwnProperty(key)) return false; | |
| return true; | |
| } | |
| var Ember = global.Ember, |
| require 'dalli' | |
| require 'memcachier' | |
| module Sprockets | |
| module Cache | |
| # A simple Memcache cache store. | |
| # | |
| # environment.cache = Sprockets::Cache::MemcacheStore.new | |
| # | |
| class MemcacheStore |