-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support
include_classes
option on dump / include_classes.rb sample …
…/ cycle.rb sample
- Loading branch information
1 parent
83b443f
commit 3b0dc2b
Showing
9 changed files
with
519 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
$LOAD_PATH.unshift File.expand_path(File.join(__dir__, '..', 'lib')) | ||
|
||
require 'yasl' | ||
|
||
class Car | ||
attr_accessor :make, | ||
:model, | ||
:year, | ||
:owner | ||
end | ||
|
||
class Person | ||
class << self | ||
def reset_count! | ||
@count = 0 | ||
end | ||
|
||
def increment_count! | ||
@count ||= 0 | ||
@count += 1 | ||
end | ||
|
||
def reset_class_count! | ||
@@class_count = 0 | ||
end | ||
|
||
def increment_class_count! | ||
@@class_count = 0 unless defined?(@@class_count) | ||
@@class_count += 1 | ||
end | ||
end | ||
|
||
attr_accessor :name, :dob, :cars | ||
|
||
def initialize | ||
self.class.increment_count! | ||
self.class.increment_class_count! | ||
end | ||
end | ||
|
||
person = Person.new | ||
person.name = 'Sean Hux' | ||
person.dob = Time.new(2017, 10, 17, 10, 3, 4) | ||
|
||
car = Car.new | ||
car.make = 'Mitsubishi' | ||
car.model = 'Eclipse' | ||
car.year = '2002' | ||
|
||
car.owner = person | ||
person.cars = [car] | ||
|
||
dump = YASL.dump(car) | ||
|
||
puts dump.inspect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
$LOAD_PATH.unshift File.expand_path(File.join(__dir__, '..', 'lib')) | ||
|
||
require 'yasl' | ||
|
||
class Car | ||
attr_accessor :make, | ||
:model, | ||
:year, | ||
:owner | ||
end | ||
|
||
class Person | ||
class << self | ||
def reset_count! | ||
@count = 0 | ||
end | ||
|
||
def increment_count! | ||
@count ||= 0 | ||
@count += 1 | ||
end | ||
|
||
def reset_class_count! | ||
@@class_count = 0 | ||
end | ||
|
||
def increment_class_count! | ||
@@class_count = 0 unless defined?(@@class_count) | ||
@@class_count += 1 | ||
end | ||
end | ||
|
||
attr_accessor :name, :dob | ||
|
||
def initialize | ||
self.class.increment_count! | ||
self.class.increment_class_count! | ||
end | ||
end | ||
|
||
person = Person.new | ||
person.name = 'Sean Hux' | ||
person.dob = Time.new(2017, 10, 17, 10, 3, 4) | ||
|
||
car = Car.new | ||
car.make = 'Mitsubishi' | ||
car.model = 'Eclipse' | ||
car.year = '2002' | ||
car.owner = person | ||
|
||
dump = YASL.dump(car, include_classes: true) | ||
|
||
puts dump.inspect |
Oops, something went wrong.