Project

democritus

0.0
No commit activity in last 3 years
No release in over 3 years
Democritus is library for building classes from reusable components.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Democritus

Build Status APACHE 2 License Code Climate Test Coverage Documentation Status

Democritus is library for building classes from reusable components.

Democritus is inspired as followup of a common pattern that I saw in the development of Sipity's form objects. It also aims to address the needs of Sipity's yet to be developed sibling application; The dissemination of processed data.

I'm looking to apply the ideas put forward in Avdi Grimm's Naught gem.

Goal

I would like to be able to declare in Ruby the following:

ApprovalForm = Democritus.build(command_namespaces: ['Sipity::DemocritusCommands', 'Democritus::ClassBuilder::Commands']) do |builder|
  builder.form do
    attributes do
      attribute(name: 'agree_to_terms_of_service', type: 'Boolean', validates: 'acceptance')
    end
    action_name(name: 'approval')
  end
end

With an ApprovalForm, I could #submit if #valid? (i.e. the agree_to_terms_of_service has been accepted).

From that point forward, I would like to be able to create the class based on a JSON description:

{
  "#command_namespaces": ["Sipity::DemocritusCommands", "Democritus::ClassBuilder::Commands"],
  "#form": {
    "#attributes": {
      "#attribute": [
        { "name": "agree_to_terms_of_service", "type": "Boolean", "validates": "acceptance" }
      ]
    },
    "#action_name": { "name": "approval" }
  }
}
ApprovalForm = Demcritus.build_from_json(json)

Roadmap

  • Rudimentary plugin command behavior
  • Create the commands that build a Sipity processing form
  • Build class from JSON configuration
    • Basic case for nested commands
    • Allow for "constantization" of command_namespaces option.