Sha256: 64cc2285bffabdaef29cff055427de271af3d23b6739a4c22f3c433b797026ba
Contents?: true
Size: 817 Bytes
Versions: 4
Compression:
Stored size: 817 Bytes
Contents
module Gitea module Common module Struct class Base module AttrHelper def attrs(*s) define_method(:attrs) {s} attr_reader(*s) end end extend AttrHelper def initialize(opts = {}) extra_keys = opts.keys - attrs unless extra_keys.empty? fail Common::Exception, "Unexpected extra keys: #{extra_keys.join(', ')}" end attrs.each do |attr| instance_variable_set("@#{attr}", opts[attr]) end end def to_s attrs.map do |attr| v = instance_variable_get("@#{attr}") "#{attr.to_s}: #{v}" end.join(", ") end end # Base end # Struct end # Common end # Gitea
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
gitea-client-0.3.1 | lib/gitea/common/struct.rb |
gitea-client-0.3.0 | lib/gitea/common/struct.rb |
gitea-client-0.2.0 | lib/gitea/common/struct.rb |
gitea-client-0.1.0 | lib/gitea/common/struct.rb |