diff --git a/Gemfile b/Gemfile index eb07598..7e68002 100644 --- a/Gemfile +++ b/Gemfile @@ -25,7 +25,7 @@ gem "dry-struct" gem "dry-transaction", ">= 0.10.0" gem "dry-types" gem "dry-validation" -gem "dry-view", git: 'https://github.com/dry-rb/dry-view', branch: 'add_default_option_to_expose' +gem "dry-view", git: 'https://github.com/dry-rb/dry-view', branch: 'master' gem "bcrypt" gem "slim" gem "shrine" diff --git a/Gemfile.lock b/Gemfile.lock index 660c524..ac2759c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ GIT remote: https://github.com/dry-rb/dry-view - revision: ed909cd5234a40bc71e5f3eec8bb3d351df93845 - branch: add_default_option_to_expose + revision: 7fdb71e0b7ebe62d5deb24cbea7c9a039bd62691 + branch: master specs: dry-view (0.3.0) dry-configurable (~> 0.1) diff --git a/db/structure.sql b/db/structure.sql index 98ed14f..30ab4cd 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2,12 +2,11 @@ -- PostgreSQL database dump -- --- Dumped from database version 9.6.2 --- Dumped by pg_dump version 9.6.2 +-- Dumped from database version 9.5.3 +-- Dumped by pg_dump version 9.5.3 SET statement_timeout = 0; SET lock_timeout = 0; -SET idle_in_transaction_session_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; @@ -111,21 +110,21 @@ ALTER SEQUENCE tils_id_seq OWNED BY tils.id; -- --- Name: authors id; Type: DEFAULT; Schema: public; Owner: - +-- Name: id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY authors ALTER COLUMN id SET DEFAULT nextval('authors_id_seq'::regclass); -- --- Name: tils id; Type: DEFAULT; Schema: public; Owner: - +-- Name: id; Type: DEFAULT; Schema: public; Owner: - -- ALTER TABLE ONLY tils ALTER COLUMN id SET DEFAULT nextval('tils_id_seq'::regclass); -- --- Name: authors authors_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: authors_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY authors @@ -133,7 +132,7 @@ ALTER TABLE ONLY authors -- --- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY schema_migrations @@ -141,7 +140,7 @@ ALTER TABLE ONLY schema_migrations -- --- Name: tils tils_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: tils_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY tils @@ -170,7 +169,7 @@ CREATE INDEX tils_author_id_index ON tils USING btree (author_id); -- --- Name: tils tils_author_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - +-- Name: tils_author_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY tils diff --git a/lib/til_web/views/authors/edit.rb b/lib/til_web/views/authors/edit.rb index 6bc7637..29030bc 100644 --- a/lib/til_web/views/authors/edit.rb +++ b/lib/til_web/views/authors/edit.rb @@ -12,13 +12,13 @@ class Edit < TilWeb::View::Controller config.template = "authors/edit" end - private_expose :id - - expose :author do |id| + expose :author do |id:| authors[id] end - expose :errors, default: [] + expose :errors do |errors: []| + errors + end end end end diff --git a/lib/til_web/views/authors/new.rb b/lib/til_web/views/authors/new.rb index e81f184..a0a15f5 100644 --- a/lib/til_web/views/authors/new.rb +++ b/lib/til_web/views/authors/new.rb @@ -9,7 +9,9 @@ class New < TilWeb::View::Controller config.template = 'authors/new' end - expose :errors, default: [] + expose :errors do |errors: []| + errors + end end end end diff --git a/lib/til_web/views/authors/show.rb b/lib/til_web/views/authors/show.rb index 2d2990e..876b8b3 100644 --- a/lib/til_web/views/authors/show.rb +++ b/lib/til_web/views/authors/show.rb @@ -13,9 +13,7 @@ class Show < TilWeb::View::Controller config.template = "authors/show" end - private_expose :id - - expose :author do |id| + expose :author do |id:| TilWeb::Decorators::Author.new(authors[id]) end end diff --git a/lib/til_web/views/tils/new.rb b/lib/til_web/views/tils/new.rb index caddaa7..64de8c1 100644 --- a/lib/til_web/views/tils/new.rb +++ b/lib/til_web/views/tils/new.rb @@ -8,7 +8,9 @@ class New < TilWeb::View::Controller config.template = "tils/new" end - expose :errors, default: [] + expose :errors do |errors: []| + errors + end end end end diff --git a/lib/til_web/views/tils/show.rb b/lib/til_web/views/tils/show.rb index ed7f5f5..e20c312 100644 --- a/lib/til_web/views/tils/show.rb +++ b/lib/til_web/views/tils/show.rb @@ -12,9 +12,7 @@ class Show < TilWeb::View::Controller config.template = "tils/show" end - private_expose :id - - expose :til do |id| + expose :til do |id:| tils[id] end end