Class: FakeData::Method
- Inherits:
-
Object
- Object
- FakeData::Method
- Defined in:
- lib/fake_data/method.rb,
lib/fake_data/method/faker.rb,
lib/fake_data/method/control.rb
Defined Under Namespace
Constant Summary collapse
- METHOD_MATCHER =
TODO: problem with parsing “test()” => method = test; arguments = [“()”]
/((?<klass>[a-z_.:]+)\.)?(?<method>[a-z0-9_=\?]+)\s*(\((?<args1>.+)\)|(?<args2>.+))?\s*/i
- LEFT_BRACKET_MATCHER =
/^\(/
- RIGHT_BRACKET_MATCHER =
/\)$/
- ARGUMENT_SPLIT_MATCHER =
TODO: better argument splitting does not works with arrays, hash etc method(1, [1, 2])
/\s*,\s*/
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(raw) ⇒ Method
constructor
A new instance of Method.
- #source ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(raw) ⇒ Method
Returns a new instance of Method.
16 17 18 19 |
# File 'lib/fake_data/method.rb', line 16 def initialize raw @raw = raw @klass, @method, @arguments = parse(@raw) end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
14 15 16 |
# File 'lib/fake_data/method.rb', line 14 def arguments @arguments end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
14 15 16 |
# File 'lib/fake_data/method.rb', line 14 def klass @klass end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
14 15 16 |
# File 'lib/fake_data/method.rb', line 14 def method @method end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
14 15 16 |
# File 'lib/fake_data/method.rb', line 14 def raw @raw end |
Instance Method Details
#call ⇒ Object
25 26 27 |
# File 'lib/fake_data/method.rb', line 25 def call eval(source) end |
#source ⇒ Object
21 22 23 |
# File 'lib/fake_data/method.rb', line 21 def source make_call(klass, method, arguments) end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/fake_data/method.rb', line 29 def to_s source end |