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
ruby '2.7.1' | |
gem 'rails', github: 'rails/rails' | |
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data | |
# Action Text | |
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra' | |
gem 'okra', github: 'basecamp/okra' | |
# Drivers |
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
class PostsController < ApplicationController | |
# ... | |
def create | |
Posts::Create.call(post_params.to_h) do |result| | |
result.success do |post| | |
render json: post, status: :ok | |
end | |
result.failure do |errors| | |
render json: errors, status: :unprocessable_entity |
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 Posts | |
class Create | |
include ApplicationService | |
ValidationSchema = Dry::Schema.Params do | |
required(:title).filled(:str?) | |
optional(:body).maybe(:str?) | |
end | |
def execute(params) |
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 'dry/matcher/result_matcher' | |
module ApplicationService | |
module ClassMethods | |
def call(params, &block) | |
service_outcome = self.new.execute(params) | |
if block_given? | |
Dry::Matcher::ResultMatcher.call(service_outcome, &block) | |
else | |
service_outcome |
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 'dry/matcher/result_matcher' | |
module Posts | |
class Create | |
include Dry::Monads[:result, :do] | |
ValidationSchema = Dry::Schema.Params do | |
required(:title).filled(:str?) | |
optional(:body).maybe(:str?) | |
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
module Posts | |
class Create | |
include Dry::Monads[:result, :do] | |
ValidationSchema = Dry::Schema.Params do | |
required(:title).filled(:str?) | |
optional(:body).maybe(:str?) | |
end | |
def self.call(params) |
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 Posts | |
class Create | |
def self.call(params) | |
# Method body | |
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
const file = document.querySelector("input[type=file]").files[0]; | |
const reader = new FileReader(); | |
reader.readAsArrayBuffer(file); | |
reader.onload = () => { | |
const key = require("../arweave-keyfile.json"); | |
const arweave = Arweave.init({ | |
host: "arweave.net", | |
port: 443, |
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
pragma solidity ^0.6.0; | |
pragma experimental ABIEncoderV2; | |
import "@openzeppelin/contracts/math/SafeMath.sol"; | |
import "./EIP712Base.sol"; | |
contract EIP712MetaTransaction is EIP712Base { | |
using SafeMath for uint256; | |
bytes32 private constant META_TRANSACTION_TYPEHASH = keccak256( | |
bytes( |
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
pragma solidity ^0.6.0; | |
contract EIP712Base { | |
struct EIP712Domain { | |
string name; | |
string version; | |
uint256 chainId; | |
address verifyingContract; | |
} |
NewerOlder