Class: Fictium::Action

Inherits:
Model
  • Object
show all
Defined in:
lib/fictium/poros/action.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#postman

Constructor Details

#initialize(resource) ⇒ Action

Returns a new instance of Action.



6
7
8
9
10
11
12
# File 'lib/fictium/poros/action.rb', line 6

def initialize(resource)
  @resource = resource
  @params = ActiveSupport::HashWithIndifferentAccess.new
  @examples = []
  @tags = []
  @deprecated = false
end

Instance Attribute Details

#deprecatedObject

Returns the value of attribute deprecated.



4
5
6
# File 'lib/fictium/poros/action.rb', line 4

def deprecated
  @deprecated
end

#descriptionObject

Returns the value of attribute description.



4
5
6
# File 'lib/fictium/poros/action.rb', line 4

def description
  @description
end

#docsObject

Returns the value of attribute docs.



4
5
6
# File 'lib/fictium/poros/action.rb', line 4

def docs
  @docs
end

#examplesObject (readonly)

Returns the value of attribute examples.



3
4
5
# File 'lib/fictium/poros/action.rb', line 3

def examples
  @examples
end

#methodObject

Returns the value of attribute method.



4
5
6
# File 'lib/fictium/poros/action.rb', line 4

def method
  @method
end

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'lib/fictium/poros/action.rb', line 3

def params
  @params
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/fictium/poros/action.rb', line 4

def path
  @path
end

#resourceObject (readonly)

Returns the value of attribute resource.



3
4
5
# File 'lib/fictium/poros/action.rb', line 3

def resource
  @resource
end

#summaryObject

Returns the value of attribute summary.



4
5
6
# File 'lib/fictium/poros/action.rb', line 4

def summary
  @summary
end

#tagsObject

Returns the value of attribute tags.



4
5
6
# File 'lib/fictium/poros/action.rb', line 4

def tags
  @tags
end

Instance Method Details

#[](section) ⇒ Object



18
19
20
# File 'lib/fictium/poros/action.rb', line 18

def [](section)
  @params[section] ||= ActiveSupport::HashWithIndifferentAccess.new
end

#add_exampleObject



27
28
29
# File 'lib/fictium/poros/action.rb', line 27

def add_example
  Fictium::Example.new(self).tap { |example| examples << example }
end

#add_params_in(section, &block) ⇒ Object



22
23
24
25
# File 'lib/fictium/poros/action.rb', line 22

def add_params_in(section, &block)
  self[section].merge!(Fictium::ParameterEvaluator.new.evaluate_params(&block))
  nil
end

#combined_tagsObject



31
32
33
# File 'lib/fictium/poros/action.rb', line 31

def combined_tags
  resource.tags + tags
end

#default_exampleObject



39
40
41
# File 'lib/fictium/poros/action.rb', line 39

def default_example
  examples.find(&:default?).presence || examples.first
end

#deprecated?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/fictium/poros/action.rb', line 35

def deprecated?
  deprecated
end

#full_pathObject



14
15
16
# File 'lib/fictium/poros/action.rb', line 14

def full_path
  "#{resource.base_path}#{path}"
end