Class: RbsActiveHash::ActiveHash::Generator
- Inherits:
-
Object
- Object
- RbsActiveHash::ActiveHash::Generator
- Defined in:
- lib/rbs_active_hash/active_hash.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
: singleton(ActiveHash::Base).
-
#klass_name ⇒ Object
readonly
: String.
-
#parser ⇒ Object
readonly
: ActiveHash::Parser::Parser.
Instance Method Summary collapse
-
#generate ⇒ Object
: String.
-
#initialize(klass) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(klass) ⇒ Generator
Returns a new instance of Generator.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rbs_active_hash/active_hash.rb', line 24 def initialize(klass) #: void @klass = klass @klass_name = klass.name || "" @parser = ActiveHash::Parser::Parser.new path, = Object.const_source_location(klass_name) return unless path @parser.parse(File.read(path), klass_name.split("::").map(&:to_sym)) end |
Instance Attribute Details
#klass ⇒ Object (readonly)
: singleton(ActiveHash::Base)
19 20 21 |
# File 'lib/rbs_active_hash/active_hash.rb', line 19 def klass @klass end |
#klass_name ⇒ Object (readonly)
: String
20 21 22 |
# File 'lib/rbs_active_hash/active_hash.rb', line 20 def klass_name @klass_name end |
#parser ⇒ Object (readonly)
: ActiveHash::Parser::Parser
21 22 23 |
# File 'lib/rbs_active_hash/active_hash.rb', line 21 def parser @parser end |
Instance Method Details
#generate ⇒ Object
: String
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rbs_active_hash/active_hash.rb', line 35 def generate #: String if klass < ::ActiveFile::Base begin klass.reload rescue StandardError nil end end format(klass_decl) end |