Skip to content
Browse files

Added support for after parse callbacks.

  • Loading branch information...
1 parent 2e5bf2e commit 97693dfc5237833cbbe6ca40d750397fd6e2eaf3 @jnunemaker committed Jul 4, 2010
Showing with 366 additions and 329 deletions.
  1. +25 −15 lib/happymapper.rb
  2. +51 −314 spec/happymapper_spec.rb
  3. +290 −0 spec/support/models.rb
View
40 lib/happymapper.rb
@@ -13,19 +13,19 @@ def self.included(base)
base.instance_variable_set("@elements", {})
base.extend ClassMethods
end
-
+
module ClassMethods
def attribute(name, type, options={})
attribute = Attribute.new(name, type, options)
@attributes[to_s] ||= []
@attributes[to_s] << attribute
attr_accessor attribute.method_name.intern
end
-
+
def attributes
@attributes[to_s] || []
end
-
+
def element(name, type, options={})
element = Element.new(name, type, options)
@elements[to_s] ||= []
@@ -37,15 +37,23 @@ def content(name)
@content = name
attr_accessor name
end
-
+
+ def after_parse_callbacks
+ @after_parse_callbacks ||= []
+ end
+
+ def after_parse(&block)
+ after_parse_callbacks.push(block)
+ end
+
def elements
@elements[to_s] || []
end
-
+
def has_one(name, type, options={})
element name, type, {:single => true}.merge(options)
end
-
+
def has_many(name, type, options={})
element name, type, {:single => false}.merge(options)
end
@@ -61,11 +69,11 @@ def namespace(namespace = nil)
def tag(new_tag_name)
@tag_name = new_tag_name.to_s
end
-
+
def tag_name
@tag_name ||= to_s.split('::')[-1].downcase
end
-
+
def parse(xml, options = {})
if xml.is_a?(XML::Node)
node = xml
@@ -85,23 +93,25 @@ def parse(xml, options = {})
xpath = root ? '/' : './/'
xpath += "#{DEFAULT_NS}:" if namespace
xpath += tag_name
-
+
nodes = node.find(xpath, Array(namespace))
collection = nodes.collect do |n|
obj = new
-
- attributes.each do |attr|
- obj.send("#{attr.method_name}=",
+
+ attributes.each do |attr|
+ obj.send("#{attr.method_name}=",
attr.from_xml_node(n, namespace))
end
-
+
elements.each do |elem|
- obj.send("#{elem.method_name}=",
+ obj.send("#{elem.method_name}=",
elem.from_xml_node(n, namespace))
end
obj.send("#{@content}=", n.content) if @content
-
+
+ obj.class.after_parse_callbacks.each { |callback| callback.call(obj) }
+
obj
end
View
365 spec/happymapper_spec.rb
@@ -1,304 +1,25 @@
require File.dirname(__FILE__) + '/spec_helper.rb'
require 'pp'
require 'uri'
-
-module Analytics
- class Property
- include HappyMapper
-
- tag 'property'
- namespace 'http://schemas.google.com/analytics/2009'
- attribute :name, String
- attribute :value, String
- end
-
- class Entry
- include HappyMapper
-
- tag 'entry'
- element :id, String
- element :updated, DateTime
- element :title, String
- element :table_id, String, :namespace => 'http://schemas.google.com/analytics/2009', :tag => 'tableId'
- has_many :properties, Property
- end
-
- class Feed
- include HappyMapper
-
- tag 'feed'
- element :id, String
- element :updated, DateTime
- element :title, String
- has_many :entries, Entry
- end
-end
-
-class Feature
- include HappyMapper
- element :name, String, :tag => '.|.//text()'
-end
-
-class FeatureBullet
- include HappyMapper
-
- tag 'features_bullets'
- has_many :features, Feature
- element :bug, String
-end
-
-class Product
- include HappyMapper
-
- element :title, String
- has_one :feature_bullets, FeatureBullet
-end
-
-module FamilySearch
- class Person
- include HappyMapper
-
- attribute :version, String
- attribute :modified, Time
- attribute :id, String
- end
-
- class Persons
- include HappyMapper
- has_many :person, Person
- end
-
- class FamilyTree
- include HappyMapper
-
- tag 'familytree'
- attribute :version, String
- attribute :status_message, String, :tag => 'statusMessage'
- attribute :status_code, String, :tag => 'statusCode'
- has_one :persons, Persons
- end
-end
-
-module FedEx
- class Address
- include HappyMapper
-
- tag 'Address'
- namespace 'http://fedex.com/ws/track/v2'
- element :city, String, :tag => 'City'
- element :state, String, :tag => 'StateOrProvinceCode'
- element :zip, String, :tag => 'PostalCode'
- element :countrycode, String, :tag => 'CountryCode'
- element :residential, Boolean, :tag => 'Residential'
- end
-
- class Event
- include HappyMapper
-
- tag 'Events'
- namespace 'http://fedex.com/ws/track/v2'
- element :timestamp, String, :tag => 'Timestamp'
- element :eventtype, String, :tag => 'EventType'
- element :eventdescription, String, :tag => 'EventDescription'
- has_one :address, Address
- end
-
- class PackageWeight
- include HappyMapper
-
- tag 'PackageWeight'
- namespace 'http://fedex.com/ws/track/v2'
- element :units, String, :tag => 'Units'
- element :value, Integer, :tag => 'Value'
- end
-
- class TrackDetails
- include HappyMapper
-
- tag 'TrackDetails'
- namespace 'http://fedex.com/ws/track/v2'
- element :tracking_number, String, :tag => 'TrackingNumber'
- element :status_code, String, :tag => 'StatusCode'
- element :status_desc, String, :tag => 'StatusDescription'
- element :carrier_code, String, :tag => 'CarrierCode'
- element :service_info, String, :tag => 'ServiceInfo'
- has_one :weight, PackageWeight, :tag => 'PackageWeight'
- element :est_delivery, String, :tag => 'EstimatedDeliveryTimestamp'
- has_many :events, Event
- end
-
- class Notification
- include HappyMapper
-
- tag 'Notifications'
- namespace 'http://fedex.com/ws/track/v2'
- element :severity, String, :tag => 'Severity'
- element :source, String, :tag => 'Source'
- element :code, Integer, :tag => 'Code'
- element :message, String, :tag => 'Message'
- element :localized_message, String, :tag => 'LocalizedMessage'
- end
-
- class TransactionDetail
- include HappyMapper
-
- tag 'TransactionDetail'
- namespace 'http://fedex.com/ws/track/v2'
- element :cust_tran_id, String, :tag => 'CustomerTransactionId'
- end
-
- class TrackReply
- include HappyMapper
-
- tag 'TrackReply'
- namespace 'http://fedex.com/ws/track/v2'
- element :highest_severity, String, :tag => 'HighestSeverity'
- element :more_data, Boolean, :tag => 'MoreData'
- has_many :notifications, Notification, :tag => 'Notifications'
- has_many :trackdetails, TrackDetails, :tag => 'TrackDetails'
- has_one :tran_detail, TransactionDetail, :tab => 'TransactionDetail'
- end
-end
-
-class Place
- include HappyMapper
- element :name, String
-end
-
-class Radar
- include HappyMapper
- has_many :places, Place
-end
-
-class Post
- include HappyMapper
-
- attribute :href, String
- attribute :hash, String
- attribute :description, String
- attribute :tag, String
- attribute :time, Time
- attribute :others, Integer
- attribute :extended, String
-end
-
-class User
- include HappyMapper
-
- element :id, Integer
- element :name, String
- element :screen_name, String
- element :location, String
- element :description, String
- element :profile_image_url, String
- element :url, String
- element :protected, Boolean
- element :followers_count, Integer
-end
-
-class Status
- include HappyMapper
-
- element :id, Integer
- element :text, String
- element :created_at, Time
- element :source, String
- element :truncated, Boolean
- element :in_reply_to_status_id, Integer
- element :in_reply_to_user_id, Integer
- element :favorited, Boolean
- element :non_existent, String, :tag => 'dummy', :namespace => 'fake'
- has_one :user, User
-end
-
-class CurrentWeather
- include HappyMapper
-
- tag 'ob'
- namespace 'http://www.aws.com/aws'
- element :temperature, Integer, :tag => 'temp'
- element :feels_like, Integer, :tag => 'feels-like'
- element :current_condition, String, :tag => 'current-condition', :attributes => {:icon => String}
-end
-
-class Address
- include HappyMapper
-
- tag 'address'
- element :street, String
- element :postcode, String
- element :housenumber, String
- element :city, String
- element :country, String
-end
-
-# for type coercion
-class ProductGroup < String; end
-
-module PITA
- class Item
- include HappyMapper
-
- tag 'Item' # if you put class in module you need tag
- element :asin, String, :tag => 'ASIN'
- element :detail_page_url, URI, :tag => 'DetailPageURL', :parser => :parse
- element :manufacturer, String, :tag => 'Manufacturer', :deep => true
- element :point, String, :tag => 'point', :namespace => 'http://www.georss.org/georss'
- element :product_group, ProductGroup, :tag => 'ProductGroup', :deep => true, :parser => :new, :raw => true
- end
-
- class Items
- include HappyMapper
-
- tag 'Items' # if you put class in module you need tag
- element :total_results, Integer, :tag => 'TotalResults'
- element :total_pages, Integer, :tag => 'TotalPages'
- has_many :items, Item
- end
-end
-
-module GitHub
- class Commit
- include HappyMapper
-
- tag "commit"
- element :url, String
- element :tree, String
- element :message, String
- element :id, String
- element :'committed-date', Date
- end
-end
-
-module Backpack
- class Note
- include HappyMapper
-
- attribute :id, Integer
- attribute :title, String
- attribute :created_at, Date
-
- content :body
- end
-end
+require 'support/models'
describe HappyMapper do
-
+
describe "being included into another class" do
before do
@klass = Class.new do
include HappyMapper
-
+
def self.to_s
'Foo'
end
end
end
-
+
it "should set attributes to an array" do
@klass.attributes.should == []
end
-
+
it "should set @elements to a hash" do
@klass.elements.should == []
end
@@ -308,7 +29,7 @@ def self.to_s
@klass.attribute :name, String
}.should change(@klass, :attributes)
end
-
+
it "should allow adding an attribute containing a dash" do
lambda {
@klass.attribute :'bar-baz', String
@@ -319,7 +40,7 @@ def self.to_s
@klass.attribute :name, String
@klass.attributes.size.should == 1
end
-
+
it "should allow adding an element" do
lambda {
@klass.element :name, String
@@ -332,20 +53,20 @@ def self.to_s
}.should change(@klass, :elements)
end
-
+
it "should be able to get all elements in array" do
@klass.element(:name, String)
@klass.elements.size.should == 1
end
-
+
it "should allow has one association" do
@klass.has_one(:user, User)
element = @klass.elements.first
element.name.should == 'user'
element.type.should == User
element.options[:single] = true
end
-
+
it "should allow has many association" do
@klass.has_many(:users, User)
element = @klass.elements.first
@@ -354,20 +75,28 @@ def self.to_s
element.options[:single] = false
end
+ it "has after_parse callbacks" do
+ call1 = lambda { |doc| puts doc.inspect }
+ call2 = lambda { |doc| puts doc.inspect }
+ @klass.after_parse(&call1)
+ @klass.after_parse(&call2)
+ @klass.after_parse_callbacks.should == [call1, call2]
+ end
+
it "should default tag name to lowercase class" do
@klass.tag_name.should == 'foo'
end
-
+
it "should default tag name of class in modules to the last constant lowercase" do
module Bar; class Baz; include HappyMapper; end; end
Bar::Baz.tag_name.should == 'baz'
end
-
+
it "should allow setting tag name" do
@klass.tag('FooBar')
@klass.tag_name.should == 'FooBar'
end
-
+
it "should allow setting a namespace" do
@klass.namespace(namespace = "foo")
@klass.namespace.should == namespace
@@ -377,21 +106,29 @@ module Bar; class Baz; include HappyMapper; end; end
@klass.should respond_to(:parse)
end
end
-
+
describe "#attributes" do
it "should only return attributes for the current class" do
Post.attributes.size.should == 7
Status.attributes.size.should == 0
end
end
-
+
describe "#elements" do
it "should only return elements for the current class" do
Post.elements.size.should == 0
Status.elements.size.should == 10
end
end
-
+
+ describe "running after_parse callbacks" do
+ it "works" do
+ user = Status.parse(fixture_file('statuses.xml')).first.user
+ user.after_parse_called.should be_true
+ user.after_parse2_called.should be_true
+ end
+ end
+
it "should parse xml attributes into ruby objects" do
posts = Post.parse(fixture_file('posts.xml'))
posts.size.should == 20
@@ -404,7 +141,7 @@ module Bar; class Baz; include HappyMapper; end; end
first.others.should == 56
first.extended.should == 'ROXML is a Ruby library designed to make it easier for Ruby developers to work with XML. Using simple annotations, it enables Ruby classes to be custom-mapped to XML. ROXML takes care of the marshalling and unmarshalling of mapped attributes so that developers can focus on building first-class Ruby classes.'
end
-
+
it "should parse xml elements to ruby objcts" do
statuses = Status.parse(fixture_file('statuses.xml'))
statuses.size.should == 20
@@ -426,7 +163,7 @@ module Bar; class Baz; include HappyMapper; end; end
first.user.protected.should be_false
first.user.followers_count.should == 486
end
-
+
it "should parse xml containing the desired element as root node" do
address = Address.parse(fixture_file('address.xml'), :single => true)
address.street.should == 'Milchstrasse'
@@ -474,7 +211,7 @@ module Bar; class Baz; include HappyMapper; end; end
third.places[0].name.should == 'Work'
third.places[1].name.should == 'Home'
end
-
+
it "should parse xml that has elements with dashes" do
commit = GitHub::Commit.parse(fixture_file('commit.xml'))
commit.message.should == "move commands.rb and helpers.rb into commands/ dir"
@@ -483,7 +220,7 @@ module Bar; class Baz; include HappyMapper; end; end
commit.committed_date.should == Date.parse("2008-03-02T16:45:41-08:00")
commit.tree.should == "28a1a1ca3e663d35ba8bf07d3f1781af71359b76"
end
-
+
it "should parse xml with no namespace" do
product = Product.parse(fixture_file('product_no_namespace.xml'), :single => true)
product.title.should == "A Title"
@@ -492,7 +229,7 @@ module Bar; class Baz; include HappyMapper; end; end
product.feature_bullets.features[0].name.should == 'This is feature text 1'
product.feature_bullets.features[1].name.should == 'This is feature text 2'
end
-
+
it "should parse xml with default namespace" do
product = Product.parse(fixture_file('product_default_namespace.xml'), :single => true)
product.title.should == "A Title"
@@ -501,7 +238,7 @@ module Bar; class Baz; include HappyMapper; end; end
product.feature_bullets.features[0].name.should == 'This is feature text 1'
product.feature_bullets.features[1].name.should == 'This is feature text 2'
end
-
+
it "should parse xml with single namespace" do
product = Product.parse(fixture_file('product_single_namespace.xml'), :single => true)
product.title.should == "A Title"
@@ -510,7 +247,7 @@ module Bar; class Baz; include HappyMapper; end; end
product.feature_bullets.features[0].name.should == 'This is feature text 1'
product.feature_bullets.features[1].name.should == 'This is feature text 2'
end
-
+
it "should parse xml with multiple namespaces" do
track = FedEx::TrackReply.parse(fixture_file('multiple_namespaces.xml'))
track.highest_severity.should == 'SUCCESS'
@@ -567,34 +304,34 @@ module Bar; class Baz; include HappyMapper; end; end
note.title.should == 'Your world!'
note.body.should include("Also pretty")
end
-
+
it "should be able to parse google analytics api xml" do
data = Analytics::Feed.parse(fixture_file('analytics.xml'))
data.id.should == 'http://www.google.com/analytics/feeds/accounts/nunemaker@gmail.com'
data.entries.size.should == 4
-
+
entry = data.entries[0]
entry.title.should == 'addictedtonew.com'
entry.properties.size.should == 4
-
+
property = entry.properties[0]
property.name.should == 'ga:accountId'
property.value.should == '85301'
end
-
+
it "should allow instantiating with a string" do
module StringFoo
class Bar
include HappyMapper
has_many :things, 'StringFoo::Thing'
end
-
+
class Thing
include HappyMapper
end
end
end
-
+
xit "should parse family search xml" do
tree = FamilySearch::FamilyTree.parse(fixture_file('family_tree.xml'))
tree.version.should == '1.0.20071213.942'
@@ -605,15 +342,15 @@ class Thing
# tree.people.first.modified.should == Time.utc(2008, 1, 3, 16, 41, 31) # 2008-01-03T09:41:31-07:00
# tree.people.first.id.should == 'KWQS-BBQ'
end
-
+
describe 'nested elements with namespaces' do
module Namespaces
class Info
include HappyMapper
namespace 'http://schemas.google.com/analytics/2009'
element :category, String
end
-
+
class Alert
include HappyMapper
namespace 'http://schemas.google.com/analytics/2009'
@@ -629,19 +366,19 @@ class Distribution
has_one :alert, Alert
end
end
-
+
def mapping
@mapping ||= Namespaces::Distribution.parse(fixture_file('nested_namespaces.xml'))
end
it "should parse elements with inline namespace" do
lambda { mapping }.should_not raise_error
end
-
+
it "should map elements with inline namespace" do
mapping.alert.identifier.should == 'CDC-2006-183'
end
-
+
it "should map sub elements of with nested namespace" do
mapping.alert.info.category.should == 'Health'
end
@@ -650,5 +387,5 @@ def mapping
mapping.alert.severity.should == 'Severe'
end
end
-
+
end
View
290 spec/support/models.rb
@@ -0,0 +1,290 @@
+module Analytics
+ class Property
+ include HappyMapper
+
+ tag 'property'
+ namespace 'http://schemas.google.com/analytics/2009'
+ attribute :name, String
+ attribute :value, String
+ end
+
+ class Entry
+ include HappyMapper
+
+ tag 'entry'
+ element :id, String
+ element :updated, DateTime
+ element :title, String
+ element :table_id, String, :namespace => 'http://schemas.google.com/analytics/2009', :tag => 'tableId'
+ has_many :properties, Property
+ end
+
+ class Feed
+ include HappyMapper
+
+ tag 'feed'
+ element :id, String
+ element :updated, DateTime
+ element :title, String
+ has_many :entries, Entry
+ end
+end
+
+class Feature
+ include HappyMapper
+ element :name, String, :tag => '.|.//text()'
+end
+
+class FeatureBullet
+ include HappyMapper
+
+ tag 'features_bullets'
+ has_many :features, Feature
+ element :bug, String
+end
+
+class Product
+ include HappyMapper
+
+ element :title, String
+ has_one :feature_bullets, FeatureBullet
+end
+
+module FamilySearch
+ class Person
+ include HappyMapper
+
+ attribute :version, String
+ attribute :modified, Time
+ attribute :id, String
+ end
+
+ class Persons
+ include HappyMapper
+ has_many :person, Person
+ end
+
+ class FamilyTree
+ include HappyMapper
+
+ tag 'familytree'
+ attribute :version, String
+ attribute :status_message, String, :tag => 'statusMessage'
+ attribute :status_code, String, :tag => 'statusCode'
+ has_one :persons, Persons
+ end
+end
+
+module FedEx
+ class Address
+ include HappyMapper
+
+ tag 'Address'
+ namespace 'http://fedex.com/ws/track/v2'
+ element :city, String, :tag => 'City'
+ element :state, String, :tag => 'StateOrProvinceCode'
+ element :zip, String, :tag => 'PostalCode'
+ element :countrycode, String, :tag => 'CountryCode'
+ element :residential, Boolean, :tag => 'Residential'
+ end
+
+ class Event
+ include HappyMapper
+
+ tag 'Events'
+ namespace 'http://fedex.com/ws/track/v2'
+ element :timestamp, String, :tag => 'Timestamp'
+ element :eventtype, String, :tag => 'EventType'
+ element :eventdescription, String, :tag => 'EventDescription'
+ has_one :address, Address
+ end
+
+ class PackageWeight
+ include HappyMapper
+
+ tag 'PackageWeight'
+ namespace 'http://fedex.com/ws/track/v2'
+ element :units, String, :tag => 'Units'
+ element :value, Integer, :tag => 'Value'
+ end
+
+ class TrackDetails
+ include HappyMapper
+
+ tag 'TrackDetails'
+ namespace 'http://fedex.com/ws/track/v2'
+ element :tracking_number, String, :tag => 'TrackingNumber'
+ element :status_code, String, :tag => 'StatusCode'
+ element :status_desc, String, :tag => 'StatusDescription'
+ element :carrier_code, String, :tag => 'CarrierCode'
+ element :service_info, String, :tag => 'ServiceInfo'
+ has_one :weight, PackageWeight, :tag => 'PackageWeight'
+ element :est_delivery, String, :tag => 'EstimatedDeliveryTimestamp'
+ has_many :events, Event
+ end
+
+ class Notification
+ include HappyMapper
+
+ tag 'Notifications'
+ namespace 'http://fedex.com/ws/track/v2'
+ element :severity, String, :tag => 'Severity'
+ element :source, String, :tag => 'Source'
+ element :code, Integer, :tag => 'Code'
+ element :message, String, :tag => 'Message'
+ element :localized_message, String, :tag => 'LocalizedMessage'
+ end
+
+ class TransactionDetail
+ include HappyMapper
+
+ tag 'TransactionDetail'
+ namespace 'http://fedex.com/ws/track/v2'
+ element :cust_tran_id, String, :tag => 'CustomerTransactionId'
+ end
+
+ class TrackReply
+ include HappyMapper
+
+ tag 'TrackReply'
+ namespace 'http://fedex.com/ws/track/v2'
+ element :highest_severity, String, :tag => 'HighestSeverity'
+ element :more_data, Boolean, :tag => 'MoreData'
+ has_many :notifications, Notification, :tag => 'Notifications'
+ has_many :trackdetails, TrackDetails, :tag => 'TrackDetails'
+ has_one :tran_detail, TransactionDetail, :tab => 'TransactionDetail'
+ end
+end
+
+class Place
+ include HappyMapper
+ element :name, String
+end
+
+class Radar
+ include HappyMapper
+ has_many :places, Place
+end
+
+class Post
+ include HappyMapper
+
+ attribute :href, String
+ attribute :hash, String
+ attribute :description, String
+ attribute :tag, String
+ attribute :time, Time
+ attribute :others, Integer
+ attribute :extended, String
+end
+
+class User
+ include HappyMapper
+
+ element :id, Integer
+ element :name, String
+ element :screen_name, String
+ element :location, String
+ element :description, String
+ element :profile_image_url, String
+ element :url, String
+ element :protected, Boolean
+ element :followers_count, Integer
+
+ attr_accessor :after_parse_called
+ attr_accessor :after_parse2_called
+
+ after_parse do |doc|
+ doc.after_parse_called = true
+ end
+
+ after_parse do |doc|
+ doc.after_parse2_called = true
+ end
+end
+
+class Status
+ include HappyMapper
+
+ element :id, Integer
+ element :text, String
+ element :created_at, Time
+ element :source, String
+ element :truncated, Boolean
+ element :in_reply_to_status_id, Integer
+ element :in_reply_to_user_id, Integer
+ element :favorited, Boolean
+ element :non_existent, String, :tag => 'dummy', :namespace => 'fake'
+ has_one :user, User
+end
+
+class CurrentWeather
+ include HappyMapper
+
+ tag 'ob'
+ namespace 'http://www.aws.com/aws'
+ element :temperature, Integer, :tag => 'temp'
+ element :feels_like, Integer, :tag => 'feels-like'
+ element :current_condition, String, :tag => 'current-condition', :attributes => {:icon => String}
+end
+
+class Address
+ include HappyMapper
+
+ tag 'address'
+ element :street, String
+ element :postcode, String
+ element :housenumber, String
+ element :city, String
+ element :country, String
+end
+
+# for type coercion
+class ProductGroup < String; end
+
+module PITA
+ class Item
+ include HappyMapper
+
+ tag 'Item' # if you put class in module you need tag
+ element :asin, String, :tag => 'ASIN'
+ element :detail_page_url, URI, :tag => 'DetailPageURL', :parser => :parse
+ element :manufacturer, String, :tag => 'Manufacturer', :deep => true
+ element :point, String, :tag => 'point', :namespace => 'http://www.georss.org/georss'
+ element :product_group, ProductGroup, :tag => 'ProductGroup', :deep => true, :parser => :new, :raw => true
+ end
+
+ class Items
+ include HappyMapper
+
+ tag 'Items' # if you put class in module you need tag
+ element :total_results, Integer, :tag => 'TotalResults'
+ element :total_pages, Integer, :tag => 'TotalPages'
+ has_many :items, Item
+ end
+end
+
+module GitHub
+ class Commit
+ include HappyMapper
+
+ tag "commit"
+ element :url, String
+ element :tree, String
+ element :message, String
+ element :id, String
+ element :'committed-date', Date
+ end
+end
+
+module Backpack
+ class Note
+ include HappyMapper
+
+ attribute :id, Integer
+ attribute :title, String
+ attribute :created_at, Date
+
+ content :body
+ end
+end

0 comments on commit 97693df

Please sign in to comment.
Something went wrong with that request. Please try again.