Class: ApiMaker::ResultParser

Inherits:
Object
  • Object
show all
Defined in:
lib/api_maker/result_parser.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, ability: nil, api_maker_args: nil, controller: nil) ⇒ ResultParser

Returns a new instance of ResultParser.



8
9
10
11
12
# File 'lib/api_maker/result_parser.rb', line 8

def initialize(object, ability: nil, api_maker_args: nil, controller: nil)
  @object = object
  @ability = ability || controller&.__send__(:current_ability)
  @api_maker_args = api_maker_args || controller&.__send__(:api_maker_args) || {}
end

Instance Attribute Details

#abilityObject (readonly)

Returns the value of attribute ability.



2
3
4
# File 'lib/api_maker/result_parser.rb', line 2

def ability
  @ability
end

#api_maker_argsObject (readonly)

Returns the value of attribute api_maker_args.



2
3
4
# File 'lib/api_maker/result_parser.rb', line 2

def api_maker_args
  @api_maker_args
end

Class Method Details

.parse(*args) ⇒ Object



4
5
6
# File 'lib/api_maker/result_parser.rb', line 4

def self.parse(*args)
  ApiMaker::ResultParser.new(*args).result
end

Instance Method Details

#resultObject



14
15
16
# File 'lib/api_maker/result_parser.rb', line 14

def result
  parse_object(@object)
end