done: to attract the best patrons the movie houses had to ape the conventions and the standards of theatres. • [ mass noun ] behaviour that is considered acceptable or polite to most members of a society: he was an upholder of convention and correct form | [ count noun ] : the law is felt to express social conventions. 2 an agreement between states covering particular matters, especially one less formal than a treaty. the convention, signed by the six states bordering on the Black Sea, aims to prevent further pollution.
discernible in the way in which something happens or is done: a complicating factor is the change in working patterns. 4 an excellent example for others to follow: he set the pattern for subsequent study.
:address, :city, :state, :postal_code, :country, :email, :phone] end end # Params encapsulate the logic to handle some parameters from an untrusted source. # # A Params object generally doesn't include the Param module directly. Instead, it relies to one of the # more specific implementations, such as ParamsAllowed. module Params def initialize(params) @params = ActiveSupport::HashWithIndifferentAccess.new(params.to_h) end end module ParamsAllowed def self.included(base) base.include Params end def to_h @params.slice(*self.class.allowed).to_hash.symbolize_keys! end end
wrapper for the current phone validation library. module Phone WHITELIST = { "+3912312345678" => "+39 12312345678" } # Makes a plausibility check on the number. def self.plausible?(number) whitelisted?(number) || Phony.plausible?(number) end def self.format(number) whitelisted?(number) || Phony.formatted(Phony.normalize(number), parentheses: false) end
extensive change to the codebase • IncompaHbiliHes can be addressed in a single place • When and if needed, the external dependency can be replaced with li>le effort • TesHng doesn't require intensive stubbing
@adapter ||= NullAdapter.new end def resolve(name) adapter.resolve(name) end def enable_test! self.adapter = test_adapter.new end end # NullAdapter is a special adapter # that discards every resolve request. class NullAdapter def resolve(name) Result.new(name, [], []) end end class TestAdapter def resolve(*) result = @stubs.shift result ? Result.new(*result) : Result.new end end class GoAdapter BIN = File.join(Rails.root, "bin", "dsalias") def resolve(name) # end end
Models • Models MUST expose custom API to perform operaHons • Callbacks are allowed only for data integrity • Query methods in ActiveRecord::Base are not allowed outside the Models or Finders • Scopes can't be invoked directly outside Models or Finders and they exist only to support Finders
find_by_tld(identifier) end def self.find!(identifier) find(identifier) or not_found!(identifier) end def self.find_by_tld(identifier) tld = identifier.to_s.downcase enabled.where(tld: tld).take end def self.suffix_listing scope.enabled end def self.newgtld_suffixes scope.new_tlds.enabled.order_alpha end def self.gtld_suffixes scope.global_tlds.enabled.order_alpha end def self.cctld_suffixes scope.cc_tlds.enabled.order_alpha end def self.privacy_supported_tlds scope.where(whois_privacy: true).pluck(:tld) end private def self.not_found!(identifier) raise(ActiveRecord::RecordNotFound, "TLD `#{identifier}` not found") end end
this_account, DomainParams.new(params)) @domain = @result.data if @result.successful? render DomainSerializer.new(@domain), 201 else render ErrorSerializer.new(@result.error, @domain) end end end end class DomainHostingController def create @result = DomainCreateCommand.execute( command_context, this_account, domain_params) @domain = @result.data if @result.successful? redirect_to domain_path(@domain) else format.html { render action: "new" } end end end
:require_subscription!, :require_good_standing! def call(params) # code end end class Disable include Hanami::Action before :require_subscription! def call(params) # code end end end end