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
| Spree::Product.class_eval do | |
| def variants_hash | |
| product_variants = self.variants.to_a | |
| color_hash = {} | |
| option_value_variants = -> (color_id) do | |
| sizes_hash = {} | |
| option_values_for('Size').map do |option_value| | |
| size_variants = option_value.variants.to_a.keep_if do |variant| |
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
| def product_variants | |
| products = Spree::Taxon.find_by(name: 'Donations').products | |
| product_hash = {} | |
| variants = -> (product) do | |
| variant_hash = {} | |
| option_values = -> (option_type) do | |
| option_value_hash = {} |
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
| # For some reason you have to delete the cache beforehand | |
| # when you use the dart2js gem with Rails. | |
| # Just add this before_action in your controller and you're | |
| # good | |
| class ApplicationController < ActionController::Base | |
| before_action :remove_old_dart_files | |
| protect_from_forgery with: :exception |
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
| def order_params | |
| params[:order] &&= params[:order].permit(*permitted_order_attributes) or {} | |
| 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
| namespace :karma do | |
| task start: :environment do | |
| with_tmp_config :start | |
| end | |
| task run: :environment do | |
| with_tmp_config :start, "--single-run" | |
| end | |
| private |
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 ApplicationService | |
| extend ActiveSupport::Concern | |
| included do | |
| attr_accessor :request | |
| def self.call(*args) | |
| # The last caller should be a controller and by using | |
| # the binding_of_caller gem, we can grab that instance. | |
| ctrl = binding.of_caller(1) |
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
| Spree::Api::OrdersController.class_eval do | |
| # Remove the default authorize, we could move this functionality into | |
| # cancan later though... | |
| # authorize! :create, Order | |
| def create | |
| order_user = if @current_user_roles.include?('admin') && order_params[:user_id] | |
| Spree.user_class.find(order_params[:user_id]) | |
| else | |
| current_api_user | |
| 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
| #!/usr/bin/env ruby | |
| class Test | |
| RUBOCOP = "rubocop" | |
| COFFEELINT = "coffeelint ." | |
| RSPEC = "spring rspec spec" | |
| KARMA = "spring rake karma:run" | |
| BRAKEMAN = "brakeman -A --summary -q" | |
| def initialize |
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
| nickel-demo $ cargo run --verbose | |
| Fresh pkg-config v0.1.6 | |
| Compiling rust-mustache v0.3.0 (https://github.com/nickel-org/rust-mustache.git#fd5d0e1c) | |
| Running `rustc /Users/benmorgan/.cargo/git/checkouts/rust-mustache-b850d4795ca6321d/master/src/lib.rs --crate-name mustache --crate-type lib -g -C metadata=48f7150e9c575dbb -C extra-filename=-48f7150e9c575dbb --out-dir /Users/benmorgan/Sites/sandbox/rust/nickel-demo/target/deps --emit=dep-info,link -L dependency=/Users/benmorgan/Sites/sandbox/rust/nickel-demo/target/deps -L dependency=/Users/benmorgan/Sites/sandbox/rust/nickel-demo/target/deps -Awarnings` | |
| Fresh nickel_macros v0.0.1 (https://github.com/nickel-org/nickel.rs.git#4e7b5dda) | |
| Fresh rustc-serialize v0.2.9 | |
| Fresh phantom v0.0.3 | |
| Fresh unsafe-any v0.2.1 | |
| Fresh matches v0.1.2 | |
| Fresh libc v0.1.0 |
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 Spree | |
| class CheckoutService | |
| include ApplicationService | |
| attr_reader :order, :order_params | |
| def call(order, order_params) | |
| @order, @order_params = order, order_params | |
| order.email ||= order.user.email |