Class: Rubyists::Linear::BaseModel
- Inherits:
-
Object
- Object
- Rubyists::Linear::BaseModel
show all
- Extended by:
- GQLi::DSL, ClassMethods
- Includes:
- GQLi::DSL, SemanticLogger::Loggable
- Defined in:
- lib/linear/models/base_model.rb,
lib/linear/models/base_model/method_magic.rb,
lib/linear/models/base_model/class_methods.rb
Overview
The base model for all Linear models
Defined Under Namespace
Modules: ClassMethods, MethodMagic
Constant Summary
collapse
- CANCELLED_STATES =
%w[cancelled canceled].freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
all, all_query, allq, base_fragment, basic_filter, const_added, find, full_fragment, getter!, gql_query, just_name, many_setter!, many_to_one, one_to_many, plural, setter!
Constructor Details
#initialize(data) ⇒ BaseModel
Returns a new instance of BaseModel.
23
24
25
26
27
|
# File 'lib/linear/models/base_model.rb', line 23
def initialize(data)
data.each_key { |k| raise SmellsBad, "Unknown key #{k}" unless respond_to? "#{k}=" }
@data = data
@updated_data = data.dup
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
19
20
21
|
# File 'lib/linear/models/base_model.rb', line 19
def data
@data
end
|
#updated_data ⇒ Object
Returns the value of attribute updated_data.
19
20
21
|
# File 'lib/linear/models/base_model.rb', line 19
def updated_data
@updated_data
end
|
Instance Method Details
#cancelled_states ⇒ Object
37
38
39
|
# File 'lib/linear/models/base_model.rb', line 37
def cancelled_states
workflow_states.select { |ws| CANCELLED_STATES.include? ws.type }
end
|
#changed? ⇒ Boolean
29
30
31
|
# File 'lib/linear/models/base_model.rb', line 29
def changed?
data != updated_data
end
|
#completed_states ⇒ Object
33
34
35
|
# File 'lib/linear/models/base_model.rb', line 33
def completed_states
workflow_states.select { |ws| ws.type == 'completed' }
end
|
#inspect ⇒ Object
53
54
55
|
# File 'lib/linear/models/base_model.rb', line 53
def inspect
format '#<%<name>s:%<id>s %<inspection>s>', name: self.class.name, id:, inspection:
end
|
#inspection ⇒ Object
49
50
51
|
# File 'lib/linear/models/base_model.rb', line 49
def inspection
format('name: "%<name>s"', name:)
end
|
#to_h ⇒ Object
41
42
43
|
# File 'lib/linear/models/base_model.rb', line 41
def to_h
updated_data
end
|
#to_json(*_args) ⇒ Object
45
46
47
|
# File 'lib/linear/models/base_model.rb', line 45
def to_json(*_args)
updated_data.to_json
end
|