plexus/yaks — pull request #29 by plexus (2014-10-22 16:35:17+00:00)
Title: First major groundwork (spike) for form controls/actions

This relies on some refactoring that's already on master, notably the
Configurable module which makes the declaration of DSL's easier, and the
Attributes module, which extends Anima/Anima::Update/Anima::Defaults to
provide single functional read/write functions.

Note that Anima::Defaults isn't merged into Anima yet, it is currently
included here as AttributeDefaults.

In general I'm making a move towards making the various immutable
objects in Yaks behave in a uniform way. This means so far

- Constructor takes hash
- update(hsh) returns a new updated instance
- attribute methods can either read (no arg) or return an updated
instance (with arg)
- ==, eql?, equal?, all the Anima and Equalizer stuff
- Foo.create is a factory method that reflects how the object is created
in the DSL, e.g. Link.new uses a hash, but link 'rel', 'href' uses
positional args, so Link.create uses positional args

Tentative DSL

class FooMapper < Yaks::Mapper
control :add_user do
href '/add_user'
title 'Add a new user'
method 'POST'
media_type 'application/json'

# Here I need to do some more comparing of what info we need
# about a field.
field :name
field :age
end
end

Initially I'm aiming to add form controls that mimic HTML forms,
i.e. with discrete elements of certain types. Most likely candidate for
submitting these back would be application/x-www-form-urlencoded. Some
media types offer a template instead, either with a full templating
language, or as an example JSON object. We'll consider these later if at all.