This file contains hidden or 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 Mongoid | |
| class << self | |
| def Money(value) | |
| Money.create_from_value(value) | |
| end | |
| end | |
| class Money | |
| class << self | |
| def create_from_value(value) |
This file contains hidden or 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 Product | |
| field :traits, type: Array, default: [] | |
| after_initialize :load_traits! | |
| on_save :validates_methods | |
| def load_traits! | |
| self.traits.each do |trait| | |
| self << class | |
| self.send(:include, trait.camelize.constantize) |
This file contains hidden or 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 AutomaticExpirationDate < Molecule::Mechanics::Repercussion | |
| extend Molecule::ExchangeConcepts | |
| def act(subj, *args) | |
| subj.pricing.expiry = self.class.expires_day_before(subj.tenor_start) if subj.option? | |
| # Molecule::ExchangeConcepts.expires_day_before is .get_expiry *without* the call to .calculate_expiry | |
| end | |
| end |
This file contains hidden or 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
| ng_products = Product.where(:"commodity.name" => /ng/i).each do |p| | |
| p.expiry_rule = :preceeding_weekday | |
| end |
This file contains hidden or 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
| MyObject = { | |
| respondToCallback: function (response, context) { | |
| // context will === "abc123" when called via doingSomething() | |
| }, | |
| doingSomething: function(callback) { | |
| var _foo = "abc123"; | |
| var _self = this; | |
| var _default_callback = function (resp, status, jqxhr) { | |
| _self.respondToCallback(response, _foo); | |
| }; |
This file contains hidden or 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
| shared_context "widget" do | |
| let(:widget_klass) { self.described_class } | |
| let(:widget_name) { widget_klass.to_s.underscore.gsub(/_widget/, '') } | |
| let(:widget_instance) { root.find_widget(widget_name) } | |
| let(:current_user) { create(:user) } | |
| before { | |
| self.class.has_widgets do |r| | |
| r << widget(widget_name) | |
| end |
This file contains hidden or 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 Audit | |
| include Mongoid::Document | |
| include Mongoid::Timestamps | |
| include RailsAdminImport::Import | |
| class << self | |
| def create_with_type_message_meta(_type, _message, _user) | |
| self.create_without_type_message_meta({ | |
| :type => _type, | |
| :content => _message, |
This file contains hidden or 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
| ko.bindingHandlers.visualize = { | |
| update: function (elem, acc, all, ctx, vm) { | |
| vm.visualization.update(); | |
| }, | |
| init: function (elem, acc, all, ctx, vm) { | |
| var _options = ko.utils.unwrapObservable(acc)(); | |
| var _data = (_options.data() || []); | |
| var _height = _options.height || 250; | |
| var _width = _options.width || 506; | |
| var _default_color_scheme = 'cool'; // other options: 'spectrum14', 'colorwheel', 'spectrum2000', 'spectrum2001', 'classic9' |
This file contains hidden or 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
| ko.bindingHandlers.daterangepicker = { | |
| _defaultStart: function () { | |
| return moment().add('months', 1).startOf('month').toDate(); | |
| }, | |
| _defaultEnd: function () { | |
| return moment().add('months', 1).startOf('month').add('years', 1).subtract('days', 1).toDate(); | |
| }, | |
| _deriveStartDate: function (_options) { |
This file contains hidden or 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
| function generateLead (lead, _callback) { | |
| var _lead = { | |
| id: lead.correlationId || generateCorrelationId(), | |
| foo: 'foo', | |
| bar: 'bar' | |
| }; | |
| var _respond = function (attrs) { | |
| _callback($.extend(attrs, _lead)); //invoke the _callback provided by client | |
| }; | |
| clarity.inquireAsync(lead, function (_data) { |