Sha256: f9c2ba4fe432f047e4592f47e1f648519aab2616852de2f44dbe62d6d28f30e1
Contents?: true
Size: 453 Bytes
Versions: 2
Compression:
Stored size: 453 Bytes
Contents
module Ivy module Serializers class Attribute def initialize(name, &getter) @name = name @getter = getter || method(:default_getter) end def generate(generator, resource) generator.attribute(@name, get(resource)) end private def default_getter(resource) resource.public_send(@name) end def get(resource) @getter.call(resource) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ivy-serializers-0.2.0 | lib/ivy/serializers/attribute.rb |
ivy-serializers-0.1.0 | lib/ivy/serializers/attribute.rb |