Module: RgssDb::Jsonable
- Included in:
- Color, RPG::Actor, RPG::Animation, RPG::Animation::Frame, RPG::Animation::Timing, RPG::Area, RPG::Armor, RPG::AudioFile, RPG::BGM, RPG::BGS, RPG::BaseItem, RPG::BaseItem::Feature, RPG::Class, RPG::Class::Learning, RPG::CommonEvent, RPG::Enemy, RPG::Enemy::Action, RPG::Enemy::DropItem, RPG::EquipItem, RPG::Event, RPG::Event::Page, RPG::Event::Page::Condition, RPG::Event::Page::Graphic, RPG::EventCommand, RPG::Item, RPG::ME, RPG::Map, RPG::Map::Encounter, RPG::MapInfo, RPG::MoveCommand, RPG::MoveRoute, RPG::SE, RPG::Skill, RPG::State, RPG::System, RPG::System::Terms, RPG::System::TestBattler, RPG::System::Vehicle, RPG::System::Words, RPG::Tileset, RPG::Troop, RPG::Troop::Member, RPG::Troop::Page, RPG::Troop::Page::Condition, RPG::UsableItem, RPG::UsableItem::Damage, RPG::UsableItem::Effect, RPG::Weapon, Rect, Table, Tone
- Defined in:
- lib/rgss_db/model/mixins/jsonable.rb
Overview
Jsonable mixin
Instance Method Summary collapse
-
#as_json ⇒ Hash
Returns this instance as a json-ready hash.
-
#to_json(*args) ⇒ String
Converts this instance to a JSON string.
Instance Method Details
#as_json ⇒ Hash
Returns this instance as a json-ready hash
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rgss_db/model/mixins/jsonable.rb', line 13 def as_json hash = {} hash.store(JSON.create_id, self.class.name) instance_variables.each do |ivar| ivar_id = ivar.to_s.delete("@") ivar_value = instance_variable_get(ivar) hash.store(ivar_id, ivar_value) end hash end |
#to_json(*args) ⇒ String
Converts this instance to a JSON string
31 32 33 |
# File 'lib/rgss_db/model/mixins/jsonable.rb', line 31 def to_json(*args) as_json.to_json(*args) end |