Sha256: d92c5dd0e8a5cf8f4c62c864f37f077c82604f46e303fcfac9fa40180fd7fd4a
Contents?: true
Size: 1015 Bytes
Versions: 4
Compression:
Stored size: 1015 Bytes
Contents
module Yaks class Mapper class Control include Attributes.new( name: nil, href: nil, title: nil, method: nil, media_type: nil, fields: [] ), Configurable def self.create(name = nil, options = {}) new({name: name}.merge(options)) end def add_to_resource(resource, _parent_mapper, _context) resource.add_control( Resource::Control.new(to_h.merge(fields: fields.map(&:to_resource_control_field))) ) end class Field include Attributes.new(:name, label: nil, type: "text", value: nil) def self.create(*args) attrs = args.last.instance_of?(Hash) ? args.pop : {} if name = args.shift attrs = attrs.merge(name: name) end new(attrs) end def to_resource_control_field Resource::Control::Field.new(to_h) end end config_method :field, create: Field, append_to: :fields end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
yaks-0.7.1 | lib/yaks/mapper/control.rb |
yaks-0.7.0 | lib/yaks/mapper/control.rb |
yaks-0.6.2 | lib/yaks/mapper/control.rb |
yaks-0.6.1 | lib/yaks/mapper/control.rb |