No commit activity in last 3 years
No release in over 3 years
Flexible attribute mapping
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Elastic attributes¶ ↑

Flexible attribute mapper. Input any ruby structure, map sub-structures to specified classes.

Can be used to map decoded JSON structures to objects, e.g. with document-oriented databases or JSON APIs.

Examples¶ ↑

class Person
  include ElasticAttributes
  attribute :name, :is_default => true
end

class City
  include ElasticAttributes
  attribute :name, :is_default => true
  attribute :mayor, Person
end

class Country
  include ElasticAttributes
  attribute :name, :is_default => true
  attribute :cities, [Array, City] # Array of Cities
end

Country.from( 'Hungary' )
Country.from( {'name' => 'Hungary'} )
Country.from( {'name' => 'Hungary', 'cities' => ['Budapest', 'Miskolc', 'Debrecen']} )
Country.from( {'name' => 'Hungary', 'cities' => [{'name' => 'Budapest', 'mayor' => 'Demszky Gabor'},
                                                 'Miskolc', 
                                                 'Debrecen']} )
City.from( {'name' => 'Budapest', 'mayor' => 'Demszky Gabor'} )
city = City.from( {'name' => 'Budapest', 'mayor' => {'name' => 'Demszky Gabor'}} )

city.encode # => {"name"=>"Budapest", "mayor"=>"Demszky Gabor"}

Installation¶ ↑

gem install elastic_attributes

License¶ ↑

sam.zoy.org/wtfpl/