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
# List only the methods defined in that specific class | |
self.methods - self.class.ancestors.map{|x|x.methods}.flatten |
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
def Price.generate_scopes_for_state_machines | |
state_machines.each_pair do |machine_name, that_machine| | |
that_machine.states.map do |state| | |
# puts "will create these scopes: #{machine_name}_#{state.name} state: #{state.value} " | |
# puts "will create these scopes: #{machine_name}_#{state.name} state: #{state.name.to_s} " | |
# Price.scope "#{machine_name}_#{state.name}", :conditions => { machine_name => state.name.to_s } | |
Price.scope "#{machine_name}_#{state.name}", :conditions => { machine_name => state.value } | |
end | |
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
require File.expand_path('../boot', __FILE__) | |
# Pick the frameworks you want: | |
# require "active_record/railtie" | |
require "action_controller/railtie" | |
require "action_mailer/railtie" | |
# require "active_resource/railtie" | |
require "sprockets/railtie" | |
require "mongoid" | |
# require "rails/test_unit/railtie" |
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
a = -> { puts "lambda" } | |
a.class | |
def negyedik | |
puts "negyedik" | |
yield | |
end | |
def harmadik(pr) | |
puts "harmadik" |
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
# http://sinonjs.org/docs/#spies | |
# https://github.com/pivotal/jasmine/wiki/Spies | |
# http://pivotal.github.io/jasmine/ | |
# | |
class PubSub | |
subscribe: (cb) -> | |
@cb = cb | |
publish: (arg1, arg2)-> | |
@cb(arg1, arg2) |
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
# http://sinonjs.org/docs/#mocks | |
# http://pivotal.github.io/jasmine/ | |
# | |
class PubSub | |
subscribers: -> | |
@listeners ||= [] | |
@listeners | |
subscribe: (cb) -> | |
@subscribers().push cb | |
publish: (arg1, arg2)-> |
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
u = User.find '5209df7c2e21a971fd000027' | |
params = u.active_model_serializer.new(u, {}).as_json | |
roles = params[:roles] | |
roles.push( {"organization_id" => "5209df7c523f8fd8816767b3", "role" => :manager}) | |
u.update_attributes params | |
class UserSerializer < ActiveModel::Serializer | |
attributes :_id, :name, :email, :timezone, :mobile, :password, :password_confirmation, :country_calling_prefix |
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
# --- | |
# Analytics | |
term = 'dolor' | |
term = 'harmadik' | |
report = Analysis.where( {:'$and' => [{ | |
:'$or' => [ | |
{'widgets.text' => /#{term}/i}, | |
{'title' => /#{term}/i} | |
]} | |
]} |
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 MyObservers | |
module Document | |
module ClassMethods | |
def observers= (*observers) | |
declared_observers.replace(observers.flatten) | |
end | |
def declared_observers | |
@declared_observers ||= [] | |
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
get '(/o/:organization/)search/:q' => "search#show", as: :search | |
app.search_path q:'boti' | |
=> "search/boti" | |
2.0.0p0 :003 > app.search_path q:'boti', organization: 'Masik' | |
=> "/o/Masik/search/boti" |