Module: RgssDb::JsonableConstructor
- 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_constructor.rb
Overview
Jsonable constructor module
Instance Method Summary collapse
-
#json_create(hash, *args) ⇒ Object
JSON deserializer.
-
#json_new(*args) ⇒ Object
JSON constructor.
Instance Method Details
#json_create(hash, *args) ⇒ Object
JSON deserializer
31 32 33 34 35 36 37 38 |
# File 'lib/rgss_db/model/mixins/jsonable_constructor.rb', line 31 def json_create(hash, *args) instance = json_new(*args) hash.each_pair do |key, value| ivar = "@#{key}".to_sym instance.instance_variable_set(ivar, value) if instance.instance_variables.include?(ivar) end instance end |
#json_new(*args) ⇒ Object
JSON constructor
This constructor is used to create a default instance
Note: Needs to be overriden in case class constructor needs arguments
19 20 21 |
# File 'lib/rgss_db/model/mixins/jsonable_constructor.rb', line 19 def json_new(*args) new(*args) end |