Skip to content

Instantly share code, notes, and snippets.

View kopylovvlad's full-sized avatar
💭
I ❤️ Ruby

Kopylov Vladislav kopylovvlad

💭
I ❤️ Ruby
  • RamblerGroup
  • Moscow
View GitHub Profile
module UserSearcher
def self.call(params = {})
scope = ::User.active
# by id
scope = scope.find(params['id']).to_a if params['id'].present?
# simple fields
%w[first_name last_name email city].each do |item|
next unless params[item].present?
# model
class Post
include Neo4j::ActiveNode
include Neo4j::Timestamps
scope :published, -> { where(published: true) }
def self.searching(search_params)
result = Post.published
# relations
class ForgottenPasswordService
def initialize(user_email)
@user_email = user_email
@user = nil
end
def perform
find_user && generate_token && send_email
end
module Visitable
def accept(visitor)
raise 'does not implement error'
end
end
# class that accept any visitor
class User < ApplicationRecord
include Visitable
class AbstractState
def initialize(content)
@content = content
end
def status
raise 'does not implement error'
end
def publish
class LogHandler
attr_reader :successor
def initialize(successor = nil)
@successor = successor
end
def process(log_item)
if accept(log_item)
example_200 = {
path: '/admin/rubrics',
time: '2018-03-02 12:10:34 +0300',
http_status: '200',
http_method: 'POST',
parameters: {"rubric"=>{"title"=>"111", "locator"=>"111"}},
processing: {
by: 'Admin::RubricsController#create',
as: 'JS'
},
# library for generate xls-file
module RubyXLS
# a lot of code
end
# class that consis information about user
class User
# a lot of code
end
[
#<VariableAssign
@name=:"other-color",
@expression= #<VirtualString @value="red">>,
#<VariableAssign
@name=:main_color,
@expression= #<VirtualString @value="green">>,
#<Selector
@name="div",
@declaration=[
$other-color: red;
$main_color: green;
div {
color: $main_color;
p {
color: $main_color;
span {
font-size: 9px;
}