Submit Search
Upload
Data Mapper Krug 8
•
Download as PPT, PDF
•
0 likes
•
405 views
Paul Klipp
Follow
Piotr's presentation on Datamapper and Merb at the Krakow Ruby User Group
Read less
Read more
Technology
Education
Report
Share
Report
Share
1 of 49
Download now
Recommended
Trademarks rights vs. Free speech
Trademarks rights vs. Free speech
Ronald Coleman
Moving the Other Guy's Resume
Moving the Other Guy's Resume
Ronald Coleman
Fixture Replacement Plugins
Fixture Replacement Plugins
Paul Klipp
Kunstzinnige Reportages
Kunstzinnige Reportages
jongenae
Javascript Unit Testing
Javascript Unit Testing
Paul Klipp
AIPLA Spring Meeting 2010: Keying Up Keywords Ronald Coleman
AIPLA Spring Meeting 2010: Keying Up Keywords Ronald Coleman
Ronald Coleman
Electronic Document Management And Discovery
Electronic Document Management And Discovery
Ronald Coleman
ColemanRon_paper
ColemanRon_paper
Ronald Coleman
Recommended
Trademarks rights vs. Free speech
Trademarks rights vs. Free speech
Ronald Coleman
Moving the Other Guy's Resume
Moving the Other Guy's Resume
Ronald Coleman
Fixture Replacement Plugins
Fixture Replacement Plugins
Paul Klipp
Kunstzinnige Reportages
Kunstzinnige Reportages
jongenae
Javascript Unit Testing
Javascript Unit Testing
Paul Klipp
AIPLA Spring Meeting 2010: Keying Up Keywords Ronald Coleman
AIPLA Spring Meeting 2010: Keying Up Keywords Ronald Coleman
Ronald Coleman
Electronic Document Management And Discovery
Electronic Document Management And Discovery
Ronald Coleman
ColemanRon_paper
ColemanRon_paper
Ronald Coleman
“A Focus on Initial Interest Confusion, Post-Sale Confusion and Related Strat...
“A Focus on Initial Interest Confusion, Post-Sale Confusion and Related Strat...
Ronald Coleman
Krug Fat Client
Krug Fat Client
Paul Klipp
Online auction sites final report of the abcny
Online auction sites final report of the abcny
Ronald Coleman
Document review principles and privileges
Document review principles and privileges
Ronald Coleman
Into the North Presentation
Into the North Presentation
Kim Werner
XR3 Hybrid
XR3 Hybrid
Robert Q Riley
More Related Content
Viewers also liked
“A Focus on Initial Interest Confusion, Post-Sale Confusion and Related Strat...
“A Focus on Initial Interest Confusion, Post-Sale Confusion and Related Strat...
Ronald Coleman
Krug Fat Client
Krug Fat Client
Paul Klipp
Online auction sites final report of the abcny
Online auction sites final report of the abcny
Ronald Coleman
Document review principles and privileges
Document review principles and privileges
Ronald Coleman
Into the North Presentation
Into the North Presentation
Kim Werner
XR3 Hybrid
XR3 Hybrid
Robert Q Riley
Viewers also liked
(6)
“A Focus on Initial Interest Confusion, Post-Sale Confusion and Related Strat...
“A Focus on Initial Interest Confusion, Post-Sale Confusion and Related Strat...
Krug Fat Client
Krug Fat Client
Online auction sites final report of the abcny
Online auction sites final report of the abcny
Document review principles and privileges
Document review principles and privileges
Into the North Presentation
Into the North Presentation
XR3 Hybrid
XR3 Hybrid
Data Mapper Krug 8
1.
BY PIOTR SOLNICA
2.
3.
DataMapper Istniejące Implementacje
ORM November 19, 2008 © Piotr Solnica
4.
Istniejące Implementacje ORM
ActiveRecord & Sequel November 19, 2008 © Piotr Solnica
5.
Istniejące Implementacje ORM
Po co trzeci zawodnik…? November 19, 2008 © Piotr Solnica
6.
7.
8.
Istniejące implementacje ORM
November 19, 2008 © Piotr Solnica
9.
Istniejące Implementacje ORM
Poza tym wszystkim… November 19, 2008 © Piotr Solnica
10.
Istniejące Implementacje ORM
… ActiveRecord & Sequel używają… November 19, 2008 © Piotr Solnica
11.
Istniejące Implementacje ORM
MIGRACJI! November 19, 2008 © Piotr Solnica
12.
Istniejące Implementacje ORM
DataMapper November 19, 2008 © Piotr Solnica
13.
DataMapper Architektura November
19, 2008 © Piotr Solnica
14.
DataMapper / Architektura
Repozytoria MySQL CauchDB SimpleDB Adaptery Zasoby November 19, 2008 © Piotr Solnica
15.
DataMapper / Architektura
Repozytoria November 19, 2008 © Piotr Solnica
16.
17.
DataMapper / Architektura
/ Repozytoria Każdy system udostępniający dane za pomocą swojego interfejsu może stać się repozytorium DataMappera November 19, 2008 © Piotr Solnica
18.
DataMapper / Architektura
Adaptery November 19, 2008 © Piotr Solnica
19.
DataMapper / Architektura
/ Adaptery Adaptery zapewniają transparentny dostęp do danych z repozytoriów November 19, 2008 © Piotr Solnica
20.
21.
DataMapper / Architetura
Zasoby November 19, 2008 © Piotr Solnica
22.
DataMapper / Architektura
/ Zasoby Zasoby reprezentują dane z repozytoriów, za ich pośrednictwem wykonujemy operacje CRUD November 19, 2008 © Piotr Solnica
23.
DataMapper / Architektura
/ Zasoby Każdy zasób charakteryzuje się różnymi własnościami, przy czym własności te mogą być związane z różnymi repozytoriami… November 19, 2008 © Piotr Solnica
24.
DataMapper / Architektura
/ Zasoby … to my decydujemy jakie własności zasobów nas interesują, a nie zautomatyzowany do bólu ORM! November 19, 2008 © Piotr Solnica
25.
DataMapper / Architektura
/ Zasoby Pomiędzy zasobami mogą istnieć powiązania typowe dla relacyjnych baz danych (one-to-one, one-to-many etc.) November 19, 2008 © Piotr Solnica
26.
DataMapper Podstawy November
19, 2008 © Piotr Solnica
27.
DataMapper / Podstawy
dm-core & dm-more November 19, 2008 © Piotr Solnica
28.
29.
DataMapper / Podstawy
Własności modelu deklaruje się na poziomie jego klasy! class Zoo include DataMapper::Resource property :id, Serial property :name, String end November 19, 2008 © Piotr Solnica
30.
DataMapper / Podstawy
Relacje class Zoo include DataMapper::Resource property :id, Serial property :name, String has n, :animals has 1..10 , :young_animals, :class_name => ‘Animal’, :age => 1..3 end class Animal include DataMapper::Resource property :id, Serial property :name, String property :age, Integer belongs_to :zoo end November 19, 2008 © Piotr Solnica
31.
DataMapper / Podstawy
Automigracje Zoo.auto_migrate! Zoo.auto_upgrade! November 19, 2008 © Piotr Solnica
32.
DataMapper / Podstawy
Tworzenie nowych zasobów some_zoo = Zoo.create(:name => ‘Some Zoo’) some_zoo.animals.create(:name => ‘Marty’) another_zoo = Zoo.new(:name => ‘Another Zoo’) another_animal = Animal.new( :name => ‘Alex’, :zoo => another_zoo) another_zoo.save another_animal.save November 19, 2008 © Piotr Solnica
33.
DataMapper / Podstawy
Pobieranie zasobów zoo = Zoo.get(1) zoo.animals.get(1) zoo = Zoo.first(:name => ‘Some Zoo’) zoo.animals.all(:name => ‘Marty’) November 19, 2008 © Piotr Solnica
34.
DataMapper / Podstawy
Callbacks class Zoo include DataMapper::Resource property :id, Serial property :name, String before :save do name = ‘Default Name’ if name.blank? end end November 19, 2008 © Piotr Solnica
35.
DataMapper Key Features
November 19, 2008 © Piotr Solnica
36.
DataMapper / Key
Features IdentityMap repository do marty1 = Zoo.get( 1 ) marty2 = Zoo.get( 1 ) marty1.object_id == marty2.object_id # true end November 19, 2008 © Piotr Solnica
37.
DataMapper / Key
Features Animal.create(:name => ‘Marty’, :age => 12 ) marty = Animal.first(:name => 'Marty' ) marty.attribute_dirty?(:age) # false marty.age = 21 marty.attribute_dirty?(:age) # false marty.save # UPDATE `animals` SET `age` = 21 WHERE (`id` = 1) Dirty Properties Tracking November 19, 2008 © Piotr Solnica
38.
DataMapper / Key
Features class Zoo include DataMapper::Resource property :id, Serial property :description, Text end Zoo.create(:description => ‘This is a very nice zoo’) # SELECT `id` FROM `zoos` WHERE (`id` = 1) ORDER BY `id` LIMIT 1 zoo = Zoo.get(zoo1.id) # SELECT `description`, `id` FROM `zoos` WHERE (`id` = 1) ORDER BY `id` zoo.description Lazy Loading November 19, 2008 © Piotr Solnica
39.
DataMapper / Key
Features zoos = Zoo.all # nie wykonuje się żadne zapytanie! zoos.each do |zoo| # dopiero tutaj zostaną pobrane wszystkie zoo zoo.animals.each do |animal| # a tutaj wszystkie animals należące do zoos! puts "Animal #{animal.name} from #{zoo.name}" end end Strategic Eager Loading November 19, 2008 © Piotr Solnica
40.
DataMapper / Key
Features class Zoo include DataMapper::Resource property :id, Serial end class Cage include DataMapper::Resource property :id, Serial end class Animal include DataMapper::Resource property :zoo_id, :key => true property :cage_id, :key => true end Composite Keys November 19, 2008 © Piotr Solnica
41.
DataMapper / Key
Features zoo = Zoo.create cage = Cage.create(:zoo => zoo) Animal.create(:zoo => zoo, :cage => cage) animal = Animal.get(zoo.id, cage.id) Composite Keys November 19, 2008 © Piotr Solnica
42.
DataMapper / Key
Features class Zoo include DataMapper::Resource property :id, Serial property :name, String, :length => 12..64 end zoo = Zoo.new(:name => ‘Too short’) # ["Name must be between 12 and 64 characters long"] zoo.errors[:name] Auto-Validations November 19, 2008 © Piotr Solnica
43.
DataMapper / Key
Features class Article include DataMapper::Resource property :id, Serial property :title, String property :body, Text validates_present :title, : when => [:publish] validates_length :body, :minimum => 1000 , : when => [:publish] end article = Article.new article.valid_for_publish? # false article.title = 'Hello World' article.valid_for_publish? # false article.body = '...some 1000 chars text...' article.valid_for_publish? # true! Contextual Validations November 19, 2008 © Piotr Solnica
44.
DataMapper / Key
Features class User include DataMapper::Resource property :id, Serial property :postal_code, PostalCode end user = User.new(:postal_code => '12-34' ) user.valid? # false user.errors[:postal_code] # ["Postal code has an invalid format"] user.postal_code = '12-345' user.valid? # true Custom Data Types November 19, 2008 © Piotr Solnica
45.
DataMapper / Key
Features module DataMapper module Types class PostalCode < DataMapper::Type primitive String format(/^{ 2 }{ 3 }$/) end end end Custom Data Types November 19, 2008 © Piotr Solnica
46.
DataMapper Status Projektu
November 19, 2008 © Piotr Solnica
47.
DataMapper / Status
Projektu CURRENT VERSION: 0.9.6 November 19, 2008 © Piotr Solnica
48.
DataMapper Pytania? November
19, 2008 © Piotr Solnica
49.
DataMapper Dziękuję November
19, 2008 © Piotr Solnica
Download now