Skip to content

Instantly share code, notes, and snippets.

@valexl
valexl / ddd-rails-tree.txt
Last active July 15, 2021 13:34 — forked from replaid/ddd-rails-tree.txt
A Rails directory tree that expresses DDD layers and bounded contexts.
components/
my_bounded_context/
app/
presentation/
assets/
helpers/
mailers/
views/
drops/
filters/
@valexl
valexl / airbnb.txt
Last active June 7, 2018 17:42
Minimum Content Validator
1) PublishedValidator
- published_at needs to be present
2) InstantlyBookableValidator
- rental needs to be instantly bookable
3) PhotosValidator
- minimal photo size is 7
4) StateValidator
for rentals from US we need state present
5) DescriptionValidator
- needs to be longer then 50 characters,
class FormObject::PublishedPost
include ActiveModel::Model
include ActiveModel::Validations
delegate :category_id, :tag_list, to: :post
delegate :category_id=, :tag_list=, to: :post
attr_accessor :post
validates :category_id, :tag_list, presence: true
@valexl
valexl / lib_ams_seacher_base_seacher.rb
Last active August 29, 2015 14:21
Эластик поиск
class Rcntec::Ams::Searcher::BaseSeacher
#FIXME Название обязательно должно кончаться на название класса, для которого идет посик
class << self
def clean_query(query)
query = query.to_s.strip
query = query.gsub(/\s+/, " ")
query = query.gsub(/-/, " ")
query = ":" if query.length.zero?
"*#{query}*"
end