Class: Uinit::Structure::Compilers::AsJson
- Defined in:
- lib/uinit/structure/compilers/as_json.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Attributes inherited from Base
Instance Method Summary collapse
- #compile ⇒ Object
-
#initialize(mod, schema) ⇒ AsJson
constructor
A new instance of AsJson.
Methods inherited from Base
Constructor Details
#initialize(mod, schema) ⇒ AsJson
Returns a new instance of AsJson.
7 8 9 10 11 12 |
# File 'lib/uinit/structure/compilers/as_json.rb', line 7 def initialize(mod, schema) super(mod) @schema = schema @attributes = schema.class.instance_methods(false).map { schema.send(_1) } end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
14 15 16 |
# File 'lib/uinit/structure/compilers/as_json.rb', line 14 def attributes @attributes end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
14 15 16 |
# File 'lib/uinit/structure/compilers/as_json.rb', line 14 def schema @schema end |
Instance Method Details
#compile ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/uinit/structure/compilers/as_json.rb', line 16 def compile compile_method(<<~RUBY, __FILE__, __LINE__ + 1) def as_json #{compile_super} #{compile_json_attributes * "\n"} json end RUBY end |