Class: EmbeddedResourceObject
- Inherits:
-
Struct
- Object
- Struct
- EmbeddedResourceObject
- Defined in:
- lib/we_the_people/embedded_resource.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.hash_initialized(*keys) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/we_the_people/embedded_resource.rb', line 2 def self.hash_initialized(*keys) klass = Class.new(self.new(*keys)) keys = keys.map(&:to_s) klass.class_eval do define_method(:initialize) do |h| super(*h.values_at(*keys)) end end klass end |
Instance Method Details
#to_json(_) ⇒ Object
15 16 17 |
# File 'lib/we_the_people/embedded_resource.rb', line 15 def to_json(_) Hash[self.each_pair.to_a].to_json end |