Sha256: 343783b0fa40f3fde0cfca93c13b5fb75be8b0992115e1a962800a570f2636e6
Contents?: true
Size: 465 Bytes
Versions: 2
Compression:
Stored size: 465 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) if resource end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ivy-serializers-0.4.0 | lib/ivy/serializers/attribute.rb |
ivy-serializers-0.3.0 | lib/ivy/serializers/attribute.rb |