spec/support/spec_blueprints.rb in praxis-blueprints-3.2 vs spec/support/spec_blueprints.rb in praxis-blueprints-3.3
- old
+ new
@@ -1,5 +1,6 @@
+# frozen_string_literal: true
class Person < Praxis::Blueprint
attributes do
attribute :name, String, example: /[:first_name:]/
attribute :email, String, example: proc { |person| "#{person.name}@example.com" }
@@ -56,28 +57,25 @@
attribute :full_name
attribute :age
attribute :address
attribute :alive
end
-
end
-
-class Address < Praxis::Blueprint
+class Address < Praxis::Blueprint
attributes do
attribute :id, Integer
attribute :name, String
attribute :street, String
- attribute :state, String, values: %w{OR CA}
+ attribute :state, String, values: %w(OR CA)
- attribute :resident, Person, example: proc { |address,context| Person.example(context, address: address) }
+ attribute :resident, Person, example: proc { |address, context| Person.example(context, address: address) }
end
view :default do
attribute :street
attribute :state
-
end
view :circular do
attribute :resident, view: :circular
end
@@ -88,30 +86,24 @@
view :extended do
attribute :state
attribute :street
attribute :resident
end
-
end
-
class FullName < Attributor::Model
-
attributes do
attribute :first, String, example: /[:first_name:]/
attribute :last, String, example: /[:last_name:]/
end
-
end
-
-class SimpleHash < Attributor::Model
+class SimpleHash < Attributor::Model
attributes do
attribute :id, Integer
- attribute :hash, Hash
+ attribute :hash, Hash
end
end
-
class SimpleHashCollection < Attributor::Model
attributes do
attribute :id, Integer
attribute :hash_collection, Attributor::Collection.of(Hash)